Skip to content

Instantly share code, notes, and snippets.

@olbrichj
Created June 14, 2018 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olbrichj/ceaf7bf47092ed4757a534a04970c432 to your computer and use it in GitHub Desktop.
Save olbrichj/ceaf7bf47092ed4757a534a04970c432 to your computer and use it in GitHub Desktop.
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