Created
June 14, 2018 16:48
-
-
Save olbrichj/ceaf7bf47092ed4757a534a04970c432 to your computer and use it in GitHub Desktop.
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
var messages: [Message] = [] | |
func dispatch(_ message: Message) { | |
messages.append(message) | |
dispatchToPlugins() | |
} | |
func dispatchToPlugins() { | |
while messages.count > 0 { | |
for plugin in plugins { | |
plugin.dispatch(message: messages[0]) | |
} | |
messages.remove(at:0) | |
} | |
} | |
Thread1: | |
dispatch(message1) | |
Thread2: | |
dispatch(message2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment