-
Notifications
You must be signed in to change notification settings - Fork 203
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
How to hand off data to another thread for processing? #160
Comments
libmill isn't intended to be used this way and you should be designing your server more like this: http://libmill.org/tutorial.html#step7 Having said that, it is still possible:
|
I think the design does not make sense. Parsing is cheap. No need to have a separate thread/cpu-core assigned to it. Just read the data from socket and process it in a single thread. (Btw, note that actual network packets are received asynchronously by the kernel and stored in socket's rx buffer.) |
@sustrik Right, parsing is cheap - that's why I would do it within the context of libmill's coroutines. Processing, OTOH, is not - that's why I would shovel the data into a threadsafe queue for someone else to process. @raedwulf Ok, I saw step7 - but it's a bit more awkward that I want to do. I have an app that reads data from several sockets, processes the heck out of it, lays it to disk and responds to the caller. Basically, it's a multi-stage pipeline - each stage is connected via a thread-safe queue. I just really like the socket API of libmill and wish I could use it for the socket portion of my app. But it doesn't seem possible to get the data to/from the processing portion of the app without forking. Thanks for responding so quickly - I appreciate it. I'm going to close this issue. If I'm not understanding something, please let me know. |
You can still open a thread and pass data to it via a socketpair. No surprises there. Standard POSIX. |
Hi, maybe this isn't possible. But I really like the API of this library and would really like to use it.
I want to use it to handle all of my network IO and simple message parsing/framing before that data gets handed off to a real thread for processing.
pseudo code:
This generates 2 questions.
Does this make sense?
The text was updated successfully, but these errors were encountered: