[zeromq-dev] thread-safe calls?
Martin Sustrik
sustrik at 250bpm.com
Mon Aug 30 09:25:49 CEST 2010
Chuck,
>> Calling close on a socket that is not owned by that thread is not
>> safe afaik. The correct way to signal any socket is to send it a
>> message.
>
>
> How should sockets be cleaned up from languages that support
> destructors/finalizers? There will be situations where objects
> containing sockets will go out of scope and the garbage collector
> will reap them. At that time, a finalizer may be called to clean up
> the socket. That call will *always* happen from another thread.
>
> If this can never be safe, then I'll remove my socket finalizers and
> just leave a finalizer for the context objects.
The current trunk (2.1) contains the "migrating sockets between threads"
functionality.
It allows the VM to pass the unused socket from its owner thread to the
gc thread. The only requirement is that VM has to execute full memory
barrier at that point, which it surely does.
Martin
More information about the zeromq-dev
mailing list