oration icon indicating copy to clipboard operation
oration copied to clipboard

Async notifications

Open Libbum opened this issue 7 years ago • 5 comments

We have notifications from #62, but we should be able to return the response before sending the email. May need to spawn off a future, or invoke something in the rocket framework I'm currently unaware of.

Libbum avatar Nov 29 '17 12:11 Libbum

Maybe futures-awat could be helpful?

Libbum avatar Nov 29 '17 12:11 Libbum

Had a chat to the author of Rocket yesterday, he is interested in putting something like this into rocket_contrib if I get it working.

Notes: We're looking for a threadsafe queue, something like deque but with a threadsafe worker. Rayon may be using something like this under the hood, but that needs to be verified. With this queue, store a pointer to one side of the queue in Rocket's managed state so it is accessible within handlers and such. The other side of the queues would be given to a thread pool where workers can take tasks from. The endpoint of the queue stored in managed state needs to be Send + Sync.

Libbum avatar Dec 05 '17 09:12 Libbum

Just to add to that, Rayon uses coco, which is now depreciated in favour of crossbeam. There's also a crossbeam-deque which may prove to be a winner.

Libbum avatar Dec 05 '17 09:12 Libbum

Hmm... From the crossbeam-deque docs

A Deque doesn't implement Sync so it cannot be shared among multiple threads. However, it can create Stealers, and those can be easily cloned, shared, and sent to other threads. Stealers can only steal elements from the top.

Libbum avatar Dec 05 '17 09:12 Libbum

chan may actually be a decent candidate.

Libbum avatar Dec 05 '17 14:12 Libbum