| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/sync.R |
| 3 |
\name{pipe_notify} |
| 4 |
\alias{pipe_notify} |
| 5 |
\title{Pipe Notify} |
| 6 |
\usage{ |
| 7 |
pipe_notify(socket, cv, add = FALSE, remove = FALSE, flag = FALSE) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{socket}{a Socket.} |
| 11 |
|
| 12 |
\item{cv}{a 'conditionVariable' to signal, or NULL to cancel a previously set |
| 13 |
signal.} |
| 14 |
|
| 15 |
\item{add}{[default FALSE] logical value whether to signal (or cancel |
| 16 |
signal) when a pipe is added.} |
| 17 |
|
| 18 |
\item{remove}{[default FALSE] logical value whether to signal (or cancel |
| 19 |
signal) when a pipe is removed.} |
| 20 |
|
| 21 |
\item{flag}{[default FALSE] logical value whether to also set a flag in the |
| 22 |
'conditionVariable'. This can help distinguish between different types of |
| 23 |
signal, and causes any subsequent \code{\link[=wait]{wait()}} to return FALSE instead of TRUE. |
| 24 |
If a signal from the \pkg{tools} package, e.g. \code{tools::SIGINT}, or an |
| 25 |
equivalent integer value is supplied, this sets a flag and additionally |
| 26 |
raises this signal upon the flag being set. For \code{tools::SIGTERM}, the |
| 27 |
signal is raised with a 200ms grace period to allow a process to exit |
| 28 |
normally.} |
| 29 |
} |
| 30 |
\value{ |
| 31 |
Invisibly, zero on success (will otherwise error). |
| 32 |
} |
| 33 |
\description{ |
| 34 |
Signals a 'conditionVariable' whenever pipes (individual connections) are |
| 35 |
added or removed at a socket. |
| 36 |
} |
| 37 |
\details{ |
| 38 |
For add: this event occurs after the pipe is fully added to the socket. Prior |
| 39 |
to this time, it is not possible to communicate over the pipe with the |
| 40 |
socket. |
| 41 |
|
| 42 |
For remove: this event occurs after the pipe has been removed from the |
| 43 |
socket. The underlying transport may be closed at this point, and it is not |
| 44 |
possible to communicate using this pipe. |
| 45 |
} |
| 46 |
\examples{ |
| 47 |
s <- socket(listen = "inproc://nanopipe") |
| 48 |
cv <- cv() |
| 49 |
|
| 50 |
pipe_notify(s, cv, add = TRUE, remove = TRUE, flag = TRUE) |
| 51 |
cv_value(cv) |
| 52 |
|
| 53 |
s1 <- socket(dial = "inproc://nanopipe") |
| 54 |
cv_value(cv) |
| 55 |
reap(s1) |
| 56 |
cv_value(cv) |
| 57 |
|
| 58 |
pipe_notify(s, NULL, add = TRUE, remove = TRUE) |
| 59 |
s1 <- socket(dial = "inproc://nanopipe") |
| 60 |
cv_value(cv) |
| 61 |
reap(s1) |
| 62 |
|
| 63 |
(wait(cv)) |
| 64 |
|
| 65 |
close(s) |
| 66 |
|
| 67 |
} |