-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add double queue for ordered thread safe system
There are two criterias that need to be fulfilled. One is to be able to send and receive events in the same order that were emitted. The second criteria is that a handler must be able to receive and emit events. To enable this we've used a double queue system where by threads can be emitting events, which are queued up, and the emitEvent goroutines can read events from a different queue without deadlocking. When the queue that emitEvent goroutines use is depleted, the queues are swapped around so that the emitters are now filling in the empty queue and the emitEvent goroutines are reading from the filled queue.
- Loading branch information
Showing
2 changed files
with
151 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters