-
Notifications
You must be signed in to change notification settings - Fork 17
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
Eio bindings Zmq #126
Eio bindings Zmq #126
Conversation
…lays as a result to make the tests complete faster
f146b55
to
05393b2
Compare
05393b2
to
6df7c25
Compare
I don't want to just add reviewers, so I kindly ask either @Leonidas-from-XIV or @AndreasDahl to give a review on this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I am the best person to review this, since I don't know very much about Eio but here's at least my observations from the code.
} | ||
in | ||
let thread = Eio.Fiber.fork_promise ~sw (fun () -> | ||
Eio.Switch.run (fun sw -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the Eio terms here, what does the Switch
do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fibers is a lightweight thread. A switch is a collection of fibers and will run until all fibers has ended or cancelled. Daemon fibers will automatically be cancelled once all "regular" fibers has ended.
The construct here is made to control lifetime of the two fibers started. Once the main loop exits, the signalling daemon fiber will be automatically be cancelled. Creating a promise allows the caller of close
to wait until the event loop has ended (all handlers completed).
Close is meant to be a nice way to close the socket allowing all readers and writers to end. Its also possible to cancel a switch. If the parent switch (passed as arg this function) is cancelled all child fibers and switches are cancelled.
I hope this explains the construct of the fork -> switch -> fork.
(rule | ||
(alias runtest) | ||
(deps | ||
(:test test.exe)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run
implicitly creates a dependency on test
, so this could be skipped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand. Can the rule be skipped altogether?
Tried to replace the block with
(rule
(alias runtest)
(action
(run test.exe))
(package zmq-eio))
But that does not work
Thanks a lot for your comments @Leonidas-from-XIV - Really appreciated! One question about close semantics. In lwt/async, if the socket is closed any deferreds waiting on either In |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
CHANGES: * Add eio binding in zmq-eio (issuu/ocaml-zmq#126, @andersfugmann)
CHANGES: * Add eio binding in zmq-eio (issuu/ocaml-zmq#126, @andersfugmann)
Eio aware bindings for zmq.
The changes includes factoring out concurrent bindings (i.e. lwt/async/eio) to allow Eio bindings to follow the same interface.
Commits can be read one by one.
During testing I was puzzled that the Eio tests were significantly slower than the lwt/async tests, however this was due to a fault in the original tests where the delay in sending / receiving was only applied for the first loop iteration. This is also fixed.