On Tuesday, 4 August 2015 at 18:15:08 UTC, Ali Çehreli wrote:
On 08/04/2015 09:19 AM, Dicebot wrote:
receiveTimeout

I think the problem here is that the worker is busy, not even able to call that.

This sounds like sending a signal to the specific thread (with pthread_kill()) but I don't know the details of it nor whether Phobos supports it.

Ali

The problem is that it works up to a certain extent with receiveTimeout. However, if the input arrives in very short intervals, all the solutions I've come up with so far (including data sharing) fail sooner or later. New threads are spawned faster than old ones can be given the abort signal. There are ways to wait, till a given thread dies, say with a shared variable isAlive `while (isAlive) {}`, but even here I've come across problems when the input comes very fast.

I don't know how to solve this problem, because message passing follows a linear protocol (as far as I understand it) and shared variables give rise to data races. Something like pthread_kill() would indeed be useful, to terminate a thread at random. I wonder if fibers would be an option.

D-threads seem to be based on the assumption that there is no need to abort threads at random, any time. Or am I mistaken?

Reply via email to