[Spread-users] Designing a multithreaded app

Yair Amir yairamir at cnds.jhu.edu
Wed Nov 2 07:20:19 EST 2005


Hi,

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).

Cheers,

	:) Yair.


John David Duncan wrote:
> Hi,
> 
> 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?
> 
> Thanks,
> 
> JD
> 
> 
> 
> _______________________________________________
> Spread-users mailing list
> Spread-users at lists.spread.org
> http://lists.spread.org/mailman/listinfo/spread-users
> 
> 





More information about the Spread-users mailing list