1818
1919# ' Condition Variables
2020# '
21- # ' Creates a new condition variable (protected by a mutex internal to the
22- # ' object).
21+ # ' \code{cv} creates a new condition variable (protected by a mutex internal to
22+ # ' the object).
2323# '
24- # ' @return A 'conditionVariable' object.
24+ # ' @return For \strong{cv}: a 'conditionVariable' object.
25+ # '
26+ # ' For \strong{wait} and \strong{until}: (invisibly) logical TRUE, or else
27+ # ' FALSE if a flag has been set.
28+ # '
29+ # ' For \strong{.until}: (invisibly) logical TRUE if signalled, or else FALSE
30+ # ' if the timeout was reached.
31+ # '
32+ # ' For \strong{cv_value}: integer value of the condition variable.
33+ # '
34+ # ' For \strong{cv_reset} and \strong{cv_signal}: zero (invisibly).
2535# '
2636# ' @details Pass the 'conditionVariable' to the signalling forms of the
2737# ' asynchronous receive functions: \code{\link{recv_aio_signal}} or
3343# ' incrementing it by 1.
3444# '
3545# ' This will cause the R execution thread waiting on the condition variable
36- # ' using \code{\link{ wait}} or \code{\link{ until} } to wake and continue.
46+ # ' using \code{wait} or \code{until} to wake and continue.
3747# '
3848# ' For argument 'msec', non-integer values will be coerced to integer.
3949# ' Non-numeric input will be ignored and return immediately.
4252# '
4353# ' The condition internal to this 'conditionVariable' maintains a state
4454# ' (value). Each signal increments the value by 1. Each time
45- # ' \code{\link{ wait}} or \code{\link{ until}} returns (apart from due to
46- # ' timeout), the value is decremented by 1.
55+ # ' \code{wait} or \code{until} returns (apart from due to timeout), the
56+ # ' value is decremented by 1.
4757# '
48- # ' The internal condition may be inspected at any time using
49- # ' \code{\link{cv_value}} and reset using \code{\link{cv_reset}}. This
50- # ' affords a high degree of flexibility in designing complex concurrent
51- # ' applications.
58+ # ' The internal condition may be inspected at any time using \code{cv_value}
59+ # ' and reset using \code{cv_reset}. This affords a high degree of
60+ # ' flexibility in designing complex concurrent applications.
5261# '
5362# ' @section Flag:
5463# '
5564# ' The condition variable also contains a flag that certain signalling
5665# ' functions such as \code{\link{pipe_notify}} can set. When this flag has
57- # ' been set, all subsequent \code{\link{ wait}} calls will return logical
58- # ' FALSE instead of TRUE.
66+ # ' been set, all subsequent \code{wait} calls will return logical FALSE
67+ # ' instead of TRUE.
5968# '
6069# ' Note that the flag is not automatically reset, but may be reset manually
61- # ' using \code{\link{ cv_reset} }.
70+ # ' using \code{cv_reset}.
6271# '
6372# ' @examples
6473# ' cv <- cv()
65- # ' cv
6674# '
6775# ' @export
6876# '
6977cv <- function () .Call(rnng_cv_alloc )
7078
71- # ' Wait / Until
79+ # ' Condition Variables - Wait
7280# '
7381# ' \code{wait} waits on a condition being signalled by completion of an
74- # ' asynchronous receive.
82+ # ' asynchronous receive or pipe event .
7583# '
7684# ' @param cv a 'conditionVariable' object.
7785# '
78- # ' @return For \strong{wait} and \strong{until}: (invisibly) logical TRUE, or
79- # ' else FALSE if a flag has been set.
80- # '
81- # ' For \strong{.until}: (invisibly) logical TRUE if signalled, or else FALSE
82- # ' if the timeout was reached.
83- # '
84- # ' @details These synchronisation primitives take a 'conditionVariable'. See
85- # ' \code{\link{cv}} for further details of how the condition and flag
86- # ' operates.
87- # '
8886# ' @examples
89- # ' cv <- cv()
90- # '
9187# ' # wait(cv) # uncommenting will block until the cv is signalled
9288# '
89+ # ' @rdname cv
9390# ' @export
9491# '
9592wait <- function (cv ) invisible (.Call(rnng_cv_wait , cv ))
9693
97- # ' Until
94+ # ' Condition Variables - Until
9895# '
9996# ' \code{until} waits until a future time on a condition being signalled by
100- # ' completion of an asynchronous receive.
97+ # ' completion of an asynchronous receive or pipe event .
10198# '
10299# ' @param msec maximum time in milliseconds to wait for the condition variable
103100# ' to be signalled.
104101# '
105102# ' @examples
106103# ' until(cv, 10L)
107104# '
108- # ' @rdname wait
105+ # ' @rdname cv
109106# ' @export
110107# '
111108until <- function (cv , msec ) invisible (.Call(rnng_cv_until , cv , msec ))
112109
113- # ' @rdname wait
110+ # ' @rdname cv
114111# ' @export
115112# '
116113.until <- function (cv , msec ) invisible (.Call(rnng_cv_until2 , cv , msec ))
117114
118- # ' Condition Variables - Utilities
115+ # ' Condition Variables - Value
119116# '
120117# ' \code{cv_value} inspects the internal value of a condition variable.
121118# '
122- # ' @inheritParams wait
123- # '
124- # ' @return For \strong{cv_value}: integer value of the condition variable.
125- # '
126- # ' For \strong{cv_reset} and \strong{cv_signal}: zero (invisibly).
127- # '
128- # ' @details These functions work with a 'conditionVariable'. See \code{\link{cv}}
129- # ' for further details of how the condition and flag operates.
130- # '
131119# ' @examples
132- # ' cv <- cv()
133- # '
134120# ' cv_value(cv)
135121# '
122+ # ' @rdname cv
136123# ' @export
137124# '
138125cv_value <- function (cv ) .Call(rnng_cv_value , cv )
@@ -144,7 +131,7 @@ cv_value <- function(cv) .Call(rnng_cv_value, cv)
144131# ' @examples
145132# ' cv_reset(cv)
146133# '
147- # ' @rdname cv_value
134+ # ' @rdname cv
148135# ' @export
149136# '
150137cv_reset <- function (cv ) invisible (.Call(rnng_cv_reset , cv ))
@@ -154,10 +141,11 @@ cv_reset <- function(cv) invisible(.Call(rnng_cv_reset, cv))
154141# ' \code{cv_signal} signals a condition variable.
155142# '
156143# ' @examples
144+ # ' cv_value(cv)
157145# ' cv_signal(cv)
158146# ' cv_value(cv)
159147# '
160- # ' @rdname cv_value
148+ # ' @rdname cv
161149# ' @export
162150# '
163151cv_signal <- function (cv ) invisible (.Call(rnng_cv_signal , cv ))
@@ -169,9 +157,9 @@ cv_signal <- function(cv) invisible(.Call(rnng_cv_signal, cv))
169157# '
170158# ' @param socket a Socket.
171159# ' @param cv a 'conditionVariable' to signal.
172- # ' @param cv2 [default NULL] optionally, if specified, a second 'conditionVariable'
173- # ' to signal. Note that this cv is signalled sequentially after the first
174- # ' condition variable.
160+ # ' @param cv2 [default NULL] optionally, if specified, a second
161+ # ' 'conditionVariable' to signal. Note that this cv is signalled
162+ # ' sequentially after the first condition variable.
175163# ' @param add [default FALSE] logical value whether to signal when a pipe is
176164# ' added.
177165# ' @param remove [default FALSE] logical value whether to signal when a pipe is
0 commit comments