On Tue, 10 Oct 2017 12:07:08 GMT, Markus wrote:
On Mon, 9 Oct 2017 23:03:42 +0200, Sönke Ludwig wrote:
Currently, concurrent writes are forbidden and will usually lead to an
assertion failure. ATaskMutex
needs to be used to ensure exclusive
access. The same applies also to concurrent reads.
Got it! however I really like lock-free development.
Do you think something likeQueue writeQueue; runTask({ // I'm the writing task while (writeQueue.pop(...)) { // do the writing } }); asyncTask({ writeQueue.push({ // do the send }); }); writeQueue.push({ // do another send });
would be nicer?
if so, could you point me in the right direction.
I only found "core.task.MessageQueue", but I'm not sure it'd be the right choice. Or maybe rather like in the chat tutorial by usingManualEvent
on combination with a simpleubyte[]
list?
The ready-to-use solution to this would be using the message passing API of std.concurrency
, which integrates with vibe.d's task/fiber model. There is also an initial sketch of a Go-like channel implementation for vibe-core, which would be faster and strongly typed. It's not finished yet, but you could simply use a copy of it: https://github.com/vibe-d/vibe-core/pull/25