gj icon indicating copy to clipboard operation
gj copied to clipboard

gj::mpsc ?

Open maurer opened this issue 8 years ago • 0 comments

Now that we have promise-based IO, it would be nice to have something similar to Rust's mpsc with an interface like gj::io::tcp or gj::io::unix which returns a Promise.

My particular use case is to allow a control channel so that thread 1 can spawn thread 2, which enters an infinite gj event loop, and then later thread 1 can tell thread 2 to finish its business and shut down, but it seems like this could see broader usage.

If someone not looking to develop gj is reading this, and the feature is yet unimplemented, one hack you can use is to just alternate between waiting on promises and try_accept()ing off a mpsc channel, and poking the event loop with a dummy connection that you immediately close to cause the promise to resolve and the loop to spin around.

maurer avatar Jan 11 '16 22:01 maurer