Re: [gnet] (OT?) gnet & threads



Axel,

Only asynchronous DNS uses threads.  *But* the callback will be from the
main thread, so you never need to worry about simultaneous GNet callbacks.
Internally, GNet does not use mutexes.  If more than one thread can access
to a GNet object, you should protect it with a mutex.

The output may be coming from async DNS, if you're using that.  I don't
recall if GLib is using threads internally.  I don't think so, but I may
be wrong.

And to answer your last email:

Frequently programmers have one thread per socket.  In a client, they will
use one thread per connection.  In a server, a main thread will accept a
connection, create a new thread, and have that thread handle the
connection.  Steven's Unix Network Programming explains in great depth how
to do this with pthreads.

David


On 22 Nov 2002, Axel Bock wrote:

> Hi again,
>
> you remember my question about gnet & threads? I wondered a bit why my
> debugger always showed "new thread" in the status line, and run "ldd" on
> my program.
>
> the output was:
> [...]
> libgthread-2.0.so.0 => /usr/lib/libgthread-2.0.so.0 (0x400b0000)
> libpthread.so.0 => /lib/libpthread.so.0 (0x400b6000)
> [...]
>
> now where do these come from? (gnet? glib? why glib? what else? ... I'm
> wondering ... :-)
>
> the problem is when I dont know which "things" are threaded I cannot put
> up with a secure mutex structure to secure parallel data write access
> ... .
>
>
> thanks again and greetings,
>
> 		axel.
>
>
> _______________________________________________
> gnet mailing list
> gnet gnetlibrary org
> http://www.gnetlibrary.org/mailman/listinfo/gnet
>

-- 
      __          _    __ David Helder - dhelder umich edu
  ___/ /__ __  __(_)__/ / <http://www.eecs.umich.edu/~dhelder>
 / _  / _ `/ |/ / / _  /  DiaWebLog: <http://www.diaweblog.org>
 |_,_/|_,_/|___/_/|_,_/   Paper CD Case: <http://www.papercdcase.com>




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]