On Sun, 07 Dec 2014 05:27:50 GMT, Etienne Cimon wrote:

On Sat, 06 Dec 2014 18:18:42 GMT, yawniek wrote:

=> how can i share a WorkerTask's id with tasks started from main (so those can message the worker)?

A worker task still has access to the global scope. You can set the Tid from the worker task in this gobal scope:

__gshared Tid g_worker; 
__gshared TaskMutex g_mtx;

Any regular task can consult the global scope to figure out how to communicate with it. Use something like this:

synchronized(g_mtx)
	g_worker.send( ... )

Is your leveldb wrapper doing blocking TCP or is it just an embedded connector? It seems odd having to put it in a foreign thread, but I've done this already for async files:

https://github.com/etcimon/libasync/blob/master/source/libasync/threads.d

Thanks Etienne, very helpful hints.

i probably want your async branch as soon as i start to shard over multiple leveldb backends.
and yes indeed, leveldb does block. My benchmark inserts around 70M 128bit keys (no values) in 4M batches, when writing the batch it takes a few seconds. (4M was empirically the best batch size on my macbook, https://gist.github.com/yannick/b638cab9f76d845446da).

not sure on how to handle reads though, is there a way to do blocking calls into Workers or do i need to send a struct with the sender and then reply?
maybe i go back to just having a fiber and then buffer writes within a decoupled server that also does the sharding.