On Tuesday, 12 February 2013 at 00:09:40 UTC, FG wrote:
On 2013-02-11 22:37, monarch_dodra wrote:
Basically, I can't help but feel the thing has an hopelessly
thread-global
"mailbox" approach to the problem. This is all fine and dandy
if there is only a
single "canal" of communication between the master and the
child/children.
What thread-global? Every mbox is in thread-local storage.
Yes, but there is only one global mailbox per thread. If I have
more than one class instance inside a thread trying to
communicate with other threads, they have to share the box.
But what happens if you have 2 objects at once that want to
communicate with
their children? They have to share the global mailbox, making
things very complex.
Caller locks the callee mailbox for a moment to put a message.
Doesn't lock any other thread, so you can have N/2 threads
writing to other N/2 at the same time.
I think there is a misunderstanding about what I meant by "global
mailbox".
In my program, I have simple objects: "Manager"s, that spawn a
child thread to
do work. This works fine if I have a single Manager, but how
do I manage having
2 Managers at once?
It's generally a very bad idea to have more than 1 manager over
one's head. :)
What should a manager do if it calls "receive", and notices
the message wasn't
meant for him?
Don't know. Kill the messenger perhaps? :)