[Spread-users] Designing a multithreaded app
yairamir at cnds.jhu.edu
Wed Nov 2 07:20:19 EST 2005
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 blocked
threads if more than one of them would like to read a message at the same time.
Anyway - I think it is bad practice to have multiple threads trying to read
at the same time from a single connection. If you are not doing that then
I think you are ok.
However, there are applications and architecture that better fit a model
where every thread gets its own connection. This is fine too. Note that in
such a case, every connection (thread) has a different identity (private
name, private address, etc) in the system.
I usually use the approach Yuval mentioned in his e-mail and use more than
one connection only if I want to connect to multiple daemons (usually on
different Spread networks). Also - one can think about two connections
to the same daemon for different priorities (although with current Spread
this will be effective only in the receiving side and not the sending side -
there are hooks for the sending side but its not implemented).
John David Duncan wrote:
> 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?
> Spread-users mailing list
> Spread-users at lists.spread.org
More information about the Spread-users