-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cancelling reactimates #199
base: master
Are you sure you want to change the base?
Conversation
"stack test" passed.
The Output "o" is passed down the call stack via "buildLater" and will eventually be added to the Network nOutputs ordered bag. It is created here because we need to return a function that removes it from the bag, but the result cannot be passed back to us from the future.
In accordance with Cabal warning message.
reactimate1 and reactimate1' are not yet tested.
The reactimate cancel function calls runStep, which modifies an MVar containing the network state. If this occurs while processing another step (typically from within "execute") then the program will lock up as the re-entrant call tries to read the MVar which is already being modified.
@HeinrichApfelmus it would be great to have your thoughts on this one. |
Thank you very much for taking the time to look into this! A.
Yes, I actually prefer the type with
that essentially use B. I'm not happy with the way that the C. The name
following the conventions from Other than that, it looks pretty good to me! Thanks again! |
Comments on pull resuest Cancelling reactimates HeinrichApfelmus#199 Changed type and name for reactimate_ and reactimate_' Introduced new functions runMomentIO_ and getEventNetwork
A. B. I agree that this is a kluge, but short of major surgery on the Making the type a C. As requested. This means we also have |
I'm personally still not set on this one. To me, cancelling a |
I share your distaste, but I can't see how to make the GC understand that a My use case involves dynamic changes to a UI. When event It might be possible to create some kind of cut-out primitive further back, so that Using PS. This PR is now so bit-rotted it's going to be easier to redo from scratch. I expect to create a new PR in the next day or two. |
I think we need to create a minimal example of the problem, and then we can start to iterate on a solution. I think what you're saying is we start with something like: f = do
execute $ e1 $> do
reactimate $ f <$> e2 This means whenever f = do
execute $ e1 $> do
e2' <- e2 `untilNext` e1
reactimate $ f <$> e2'
untilNext :: MonadMoment m => Event a -> Event b -> m Event a
untilNext e1 e2 = do
nextE2 <- once e2
switchE e1 (never <$ nextE2) We'll need to thoroughly test such a combinator, but hopefully this motivates my intentions. The other bit of work is to make sure that |
Yes, that looks like a better way. A skeleton example would be something like:
With your
|
Here is a simple demo of the problem |
Awesome, thanks @PaulJohnson! I'll see what I can do. I'm also keen to have a solution here. |
Keep me posted as well. If there's one thing that I'd like to get straight in reactive-banana, it's garbage collection. Essentially, the main tension is this: In Ollie's example, |
This is a proposed fix for #198. The
Reactive.Banana.Frameworks
is extended with the following:reactimate1
:: Event (IO ()) -> MomentIO (IO ())`And likewise there is a
reactimate1'
for future values.I'm not entirely happy with the way that the cancel operation works: it calls "runStep", so if it gets called from inside
runStep
(which I think happens duringexecute
) then the program locks up. The solution, as mentioned above, is to wrap the cancel action inforkIO
. I tried doing this insidereactimate1
but that led to non-deterministic behaviour in the tests.If there is a better way to implement this extension then I'd be happy. Having the cancellation action be of type
MomentIO ()
instead ofIO ()
would do this, but then I wouldn't be able to use it from inside a widget call-back. Of course I could set up an event to send these to a reactimate, but that seemed overkill.