
Last chance! 50% off unlimited learning
Sale ends in
Prevents further pipe connections from being established at a Socket. If a socket is locked, new pipe connections are closed before they can be added to the socket.
lock(socket, cv = NULL)unlock(socket)
Invisibly, zero on success (will otherwise error).
a Socket.
(optional) a 'conditionVariable'. If supplied, the socket is locked
only whilst the condition variable is an odd value. This is designed to
allow an initial connection, as well as subsequent re-connections after a
connection has ended, if the conditon variable is also registered with
pipe_notify
for both add and remove pipe events.
s <- socket("bus", listen = "inproc://nanolock")
s1 <- socket("bus", dial = "inproc://nanolock")
lock(s)
s2 <- socket("bus", dial = "inproc://nanolock")
send(s, "test")
recv(s1)
recv(s2)
unlock(s)
s3 <- socket("bus", dial = "inproc://nanolock")
send(s, "test")
recv(s1)
recv(s3)
close(s)
close(s1)
close(s2)
close(s3)
Run the code above in your browser using DataLab