[Spread-users] Designing a multithreaded app
John David Duncan
jdd at efn.org
Mon Dec 12 11:33:10 EST 2005
>> I'm about to start working on a multi-threaded Spread application
>> for the first time, and I have a very basic question:
>> How many times do I call SP_connect()? Do I connect once and get
>> a single mailbox that all threads can share, or should each
>> thread connect inidvidually?
> It really depends on what you want to do and the architecture of
> your system.
> Both options are available with Spread, although when using only
> one connection
> with multiple threads you will need to use the thread-safe library
> and not the
> regular library. There are also implications, mainly in terms of
> threads if more than one of them would like to read a message at
> the same time.
Here's an issue that's come up...
I have one thread (and only one, ever) looping in SP_receive for a
I was thinking I could call SP_leave on that mailbox from another
thread. The receiver would then get a self-leave message and be able
to clean up. But this doesn't seem to be happening... the receiver
gets the remaining regular messages that the local daemon had stored
for it, and then calls SP_receive again and blocks forever, never
getting the self-leave.
Is there just a bug in my code somewhere, or am I maybe expecting the
More information about the Spread-users