The TCL functions created by the module (ns_attachchannel, ns_detachchannel)
are thread safe.
However, If you attach the descriptor in 2 different threads, you'll then
have to take care yourself of the synchro.
In fact, when attached to the current interpreter, the descriptor becomes
part of it and the module is not used anymore. You can then use the
descriptor as if you opened it in the script (or thread).
So, you have to use mutexes to ensure concurrent read/writes.

Jean-Fabrice RABAUTE
Core Services
Mob: +33 (0)6 13 82 67 67

-----Message d'origine-----
De : AOLserver Discussion [mailto:[EMAIL PROTECTED]]De la part
de Dossy
Envoye : mercredi 17 juillet 2002 14:44
Objet : Re: [AOLSERVER] New module for AOLServer : share TCL channels
across interpreters

On 2002.07.17, Jean-Fabrice RABAUTE <[EMAIL PROTECTED]> wrote:
> For your first question, the answer is YES. What I am doing for my use is
> open a socket connection at AOLServer startup, detach it, and then use the
> socket descriptor in all my tcl page scripts as well as threads created
> using "ns_thread".
> When detached, the socket still remains, you just have to use the "attach"
> function to attach it in another thread or script and that's all.

Do we (the users of this module) need to create our own mutex to ensure
that no two threads are reading/writing the socket at the same time?

-- Dossy

Dossy Shiobara                       mail: [EMAIL PROTECTED]
Panoptic Computer Network             web: http://www.panoptic.com/
  "He realized the fastest way to change is to laugh at your own
    folly -- then you can let go and quickly move on." (p. 70)

Reply via email to