-
Notifications
You must be signed in to change notification settings - Fork 81
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
Add ability to execute notification on specific thread #6
Comments
Yes sure. It could be done. |
@shenfumin I'm going to add: (brief example)
So it will wait until event come in. Also can be |
thanks your information. it is good idea, i agree with you. |
Are there any updates to this? I noticed |
Hello So you can add events from any thread as this is thread safe operation but processing events (calling listeners) is done on thread which is calling Currently I'm not planning to add such feature out of the box. Maybe you can add new "perk" to bus and decide on some tag that you pass on which thread process event. If you have any suggestions I'm happy to discuss. |
the most code had been changed, but the old version may be suite for you. you can checkout the old version for this issue
then you can setup one thread to consume events asynchronously like the following
|
In the absence of a proper event loop in c++ having a secondary listen-only event bus that is thread-specific. the main issue is that the execution of the event listener must run in the thread it was allocated. Maybe there can be a thread-aware listener that implicitly creates its own "listen-only" bus. |
@gelldur actually isn't this was |
@geiseri yes you are right that was intention of
|
I think I have a use case here, but it seems to be not working. I will try to put something in wandbox. To be honest I think the best way is to have a thread-specific bus that is a subordinate of the main bus. Chances are that the thread might have a different scheduler or even event loop that would want to drive the bus. Since the bus itself is thread-safe everyone would publish back to the main one. I think the only issue you might run into is backpressure if a subordinate cant keep up. You wouldn't want to block the main bus, so you might need to introduce a TTL, or something. My current case is that I have a main thread that needs to asynchronously communicate with an IO system that runs in a different thread. I need to be able to alert the main thread listeners when a message arrives, but I also need to send messages back. Since neither can block the other the bus seems the best option. Originally I was going to have a bus for rx and a bus for tx. The problem there is that the IO is in a thread pool, and coordination pretty much nullifies any decoupling the bus has to offer. |
The only reason I would want the thread-specific ownership would be to make it explicit it was tied to that thread. Since calling process from the wrong thread can cause interesting things to happen it would be nicer to the API consumer to make that hard to do =) |
Eg. someone want to execute notification in background thread
The text was updated successfully, but these errors were encountered: