Signals a 'conditionVariable' whenever pipes (individual connections) are added or removed at a socket.
pipe_notify(socket, cv, cv2 = NULL, add = TRUE, remove = TRUE, flag = TRUE)
a Socket.
a 'conditionVariable' to signal.
[default NULL] optionally, if specified, a second 'conditionVariable' to signal. Note that this cv is signalled sequentially after the first condition variable.
[default TRUE] logical value whether to signal when a pipe is added.
[default TRUE] logical value whether to signal when a pipe is removed.
[default TRUE] logical value whether to also set a flag in the
'conditionVariable'. This can help distinguish between different types of
signal, and causes any subsequent wait
or until
to return FALSE instead of TRUE.
Invisibly, zero on success (will otherwise error).
For add: this event occurs after the pipe is fully added to the socket. Prior to this time, it is not possible to communicate over the pipe with the socket.
For remove: this event occurs after the pipe has been removed from the socket. The underlying transport may be closed at this point, and it is not possible to communicate using this pipe.
s <- socket(listen = "inproc://nanopipe")
cv <- cv()
cv2 <- cv()
pipe_notify(s, cv, cv2, add = TRUE, remove = TRUE, flag = TRUE)
cv_value(cv)
#> [1] 0
cv_value(cv2)
#> [1] 0
s1 <- socket(dial = "inproc://nanopipe")
cv_value(cv)
#> [1] 1
cv_value(cv2)
#> [1] 1
close(s1)
cv_value(cv)
#> [1] 2
cv_value(cv2)
#> [1] 2
(wait(cv))
#> [1] FALSE
(wait(cv2))
#> [1] FALSE
close(s)