Learn R Programming

nanonext (version 0.9.2)

lock: Lock / Unlock a Socket

Description

Prevents further pipe connections from being established at a Socket.

Usage

lock(socket, cv = NULL)

unlock(socket)

Value

Invisibly, zero on success (will otherwise error).

Arguments

socket

a Socket.

cv

(optional) a 'conditionVariable'. If supplied, the socket is locked only while the value of the condition variable is non-zero.

Examples

Run this code
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