Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Piotr Gawryś
@Avasil
The only way is to shift inside bruteFroce from time to time. Ideally cancelBoundary after Alex finishes new changes
Jules Ivanic
@guizmaii
bruteFroce is just pure computation.
      val bruteForce =
        Task
          .async { (scheduler, cb) =>

            scheduler.execute(new Runnable { override def run(): Unit = {
              try {
                cb(...)
              } catch {
                _ => cb(null)
              }
            } })

            Cancelable.empty
          }
what about something like that ?
This message was deleted
Oleg Pyzhcov
@oleg-py
Yeah, see that Cancelable.empty? :D
Jules Ivanic
@guizmaii
ahah
Cancelable.empty == uncancelable ?
Oleg Pyzhcov
@oleg-py
Yep
Jules Ivanic
@guizmaii
so. Impossible to kill a running Runnable ?? :’(
Oleg Pyzhcov
@oleg-py
Yeah. Monix doesn't give you Thread.interrupt()esque things. Your only way is to rewrite the logic inside.
Jules Ivanic
@guizmaii
ahah
So i’m fucked :/
Oleg Pyzhcov
@oleg-py
Effective cancellation requires either:
  1. Cleanup action specified as Cancelable
  2. Logic written as a series of Tasks, not as a single monolithic one
Fabio Labella
@SystemFw
what does the logic actually do?
Jules Ivanic
@guizmaii
compute things I can’t talk about
Fabio Labella
@SystemFw
you first need to think about what it means to cancel that at all, before thinking about what it means to do it with monix, or cats-effect, or whatever
sure, I don't need to know what things you are computing
but kinda how: are these http calls (canceling means stop waiting for a response)
or cpu computation expresses as one big thing?
the latter is impossible to cancel
it's not about monix
Jules Ivanic
@guizmaii
cpu computation
:/
Fabio Labella
@SystemFw
can you express that computation has a series of flatMap
?
Piotr Gawryś
@Avasil
I assume you have no way of splitting it?
Jules Ivanic
@guizmaii

can you express that computation has a series of flatMap

No

Oleg Pyzhcov
@oleg-py
Can you modify computation code to periodically check for an AtomicBoolean?
Jules Ivanic
@guizmaii

Can you modify computation code to periodically check for an AtomicBoolean?

Maybe but it’ll require me weeks of work I don’t have. :/

Oleg Pyzhcov
@oleg-py
Then you're left with option of Thread.interrupt() and a lot of hope
Piotr Gawryś
@Avasil
Its like "guess who" game :D
Oleg Pyzhcov
@oleg-py
Now @SystemFw will probably talk you out of it :D
Fabio Labella
@SystemFw
nah
I just want to point out that this isn't a Monix (or cats-effect) design constraint or anything
on the JVM, you can't just stop an arbitrary thing
just unplug it
the model simply doesn't allow you to do that
Jules Ivanic
@guizmaii
:/
Fabio Labella
@SystemFw
there are the various Thread.stop and interrupt primitives
they might work
they are also considered unsafe (and dangerous)
Oleg Pyzhcov
@oleg-py
Oh, there's also subprocessing
Jules Ivanic
@guizmaii
If I meet some of you one day, I’ll pay you a beer or two ! You’re always here or there to help me. Thanks a lot :)
Jules Ivanic
@guizmaii
in fact the AtomicBoolean trick can maybe do the job. #excited :smile:
Damian Reeves
@DamianReeves
Hi. Does monix provide any utility for going from a Java Future to a scala Future or a monix Task?
toxicafunk
@toxicafunk
i'm pretty sure there was an fromFuture either on task or on observable
Damian Reeves
@DamianReeves
yeah that is for a scala future
Best I can think to do is top wrap the polling required with a task, but this feels like it should exist already somewhere
toxicafunk
@toxicafunk
oh sorry, I misread