zeromq/libzmq — pull request #235 by skaller (2012-02-03 15:29:49+00:00)
Title: Thread Safe Sockets.

Add a new C API call: zmq_init_thread_safe.

When used the thread safe flag is set in the context.

When a socket is created from the C API (only!) the flag is transferred to
the created socket.

All C API calls on the socket are conditionally protected by a mutex.

No C++ code is affected semantically.

No existing C code is affected.

The storage cost is: one bool in the context and socket, and a mutex in the socket,
this is paid by everyone.

The performance cost is: Two checks on the flag occur on every C API socket call.

Multi-part messages are NOT protected by this mechanism since the gathering
occurs over several calls.

Apart from "make check" this code is currently untested.