On Tue, 19 Nov 2013 10:44:00 +0100, Sönke Ludwig wrote:

Am 18.11.2013 18:15, schrieb Atila Neves:

That crashed my app as soon as the first client connected.

I'll look into it.

Thanks!

Even if it hadn't, I'd actually want to have explicit message passing between threads. At least, I think I do. This if for a publish/subscribe system and I'm trying to optimise it further. New subscription requests aren't that common, but publishing is, and that's where most of the time is spent. I naively tried looping over the subscriptions using taskPool.parallel to see which ones to publish to and the app never went anywhere because I think all the threads were trying to write to the same socket at once. I'm not sure.

So my new idea is to keep the connections in separate threads, and when one of the connections issues a publish request, I'd send a message to all the worker threads. Then they'd be responsible for searching only their own connections to see which ones to publish to. So I'd need a way to get their Tids to do that.

You can still do that. vibe.core.concurrency uses Task as the Tid
type, Task.getThis() will yield the proper Tid for each connection
handler.

To reduce overhead, you could have a single task running in each thread
that accepts messages from other threads and distributes them to the
connection taks of its own thread. runWorkerTaskDist can be used to
start a task in each worker thread at once.

Nice. I'll try that as soon as I get distribute connections.