-
Notifications
You must be signed in to change notification settings - Fork 12
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
fix kill after write issue #17
base: main
Are you sure you want to change the base?
Conversation
The original implementation has many bugs. Just an example:
Also, I suspect there is a conceptual problem with consumers. If a consumer is merely an actor doing the read effect, then any time at which the actor is not reading it is also not a consumer. Lets say a particular actor just reads, then logs what was read, then starts again. While the actor is reading it is a consumer, but while the actor is logging it is not a consumer. Therefore, messages written while the actor is logging will not be read by that actor. Is that what anyone is expecting of bus? What is actually the expectation? What is meant by "consumer"? |
I think that bug you outlined can be fixed like this: generalBracket (pure unit)
{ killed: const pure
, failed: const pure
, completed: \cs _ → AVar.put (res' : cs) consumers
}
(AVar.take consumers) (UPDATE: not really, as if
but I understand that in some case it might miss some values tho i haven't noticed that yet. |
This is what's actually needed I think:
This way consuming function can never miss anything. using just that I was able to implement:
|
This approach fixes #11 i.e. if you have fibers reading from bus and you have
kill
immediately afterwrite
to the bus, then the write will be missed. I was able to fix that, but using same AVar.put on cell as write is doing and the kill is happening in the loop forked on initialization of the bus.I have added some comments to the code but if something is not clear or seams odd let me know.