Skip to content

Commit 6d48b4f

Browse files
committed
remove lock() and unlock()
1 parent 9001cec commit 6d48b4f

File tree

9 files changed

+16
-171
lines changed

9 files changed

+16
-171
lines changed

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ export(subscribe)
9999
export(survey_time)
100100
export(tls_config)
101101
export(transact)
102-
export(unlock)
103102
export(unresolved)
104103
export(unsubscribe)
105104
export(until)

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#### Updates
44

55
* `pipe_notify()` drops argument 'cv2' for signalling 2 condition variables on one pipe event. Use signal forwarders `%~>%` instead.
6+
* The abillity to `lock()` and `unlock()` sockets is removed.
67
* Renders it safe to serialize 'nano' and 'aio' objects - they will be inactive when unserialized.
78
* Unified Windows build system now compiles 'libmbedtls' and 'libnng' from source even on R <= 4.1 using Rtools40 or earlier.
89

R/nanonext-package.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,13 @@
9393
#' @useDynLib nanonext, .registration = TRUE
9494
#'
9595
"_PACKAGE"
96+
97+
98+
#' Lock
99+
#'
100+
#' Stub function retained for compatibility purposes only.
101+
#'
102+
#' @keywords internal
103+
#' @export
104+
#'
105+
lock <- function() {} # may be removed after mirai > 2.1.0 is released

R/sync.R

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -213,51 +213,6 @@ cv_signal <- function(cv) invisible(.Call(rnng_cv_signal, cv))
213213
pipe_notify <- function(socket, cv, add = FALSE, remove = FALSE, flag = FALSE)
214214
invisible(.Call(rnng_pipe_notify, socket, cv, add, remove, flag))
215215

216-
#' Lock / Unlock a Socket
217-
#'
218-
#' Prevents further pipe connections from being established at a Socket. If a
219-
#' socket is locked, new pipe connections are closed before they can be added to
220-
#' the socket.
221-
#'
222-
#' @param socket a Socket.
223-
#' @param cv (optional) a \sQuote{conditionVariable}. If supplied, the socket is
224-
#' locked only whilst the condition variable is an odd value. This is designed
225-
#' to allow an initial connection, as well as subsequent re-connections after
226-
#' a connection has ended, if the conditon variable is also registered with
227-
#' \code{\link{pipe_notify}} for both add and remove pipe events.
228-
#'
229-
#' @return Invisibly, zero on success (will otherwise error).
230-
#'
231-
#' @examples
232-
#' s <- socket("bus", listen = "inproc://nanolock")
233-
#' s1 <- socket("bus", dial = "inproc://nanolock")
234-
#' lock(s)
235-
#' s2 <- socket("bus", dial = "inproc://nanolock")
236-
#'
237-
#' send(s, "test")
238-
#' recv(s1)
239-
#' recv(s2)
240-
#'
241-
#' unlock(s)
242-
#' s3 <- socket("bus", dial = "inproc://nanolock")
243-
#' send(s, "test")
244-
#' recv(s1)
245-
#' recv(s3)
246-
#'
247-
#' close(s)
248-
#' close(s1)
249-
#' close(s2)
250-
#' close(s3)
251-
#'
252-
#' @export
253-
#'
254-
lock <- function(socket, cv = NULL) invisible(.Call(rnng_socket_lock, socket, cv))
255-
256-
#' @rdname lock
257-
#' @export
258-
#'
259-
unlock <- function(socket) invisible(.Call(rnng_socket_unlock, socket))
260-
261216
#' Signal Forwarder
262217
#'
263218
#' Forwards signals from one \sQuote{conditionVariable} to another.

man/lock.Rd

Lines changed: 5 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/init.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,6 @@ static const R_CallMethodDef callMethods[] = {
181181
{"rnng_set_promise_context", (DL_FUNC) &rnng_set_promise_context, 2},
182182
{"rnng_signal_thread_create", (DL_FUNC) &rnng_signal_thread_create, 2},
183183
{"rnng_sleep", (DL_FUNC) &rnng_sleep, 1},
184-
{"rnng_socket_lock", (DL_FUNC) &rnng_socket_lock, 2},
185-
{"rnng_socket_unlock", (DL_FUNC) &rnng_socket_unlock, 1},
186184
{"rnng_stats_get", (DL_FUNC) &rnng_stats_get, 2},
187185
{"rnng_status_code", (DL_FUNC) &rnng_status_code, 1},
188186
{"rnng_stream_close", (DL_FUNC) &rnng_stream_close, 1},

src/nanonext.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,6 @@ SEXP rnng_set_opt(SEXP, SEXP, SEXP);
348348
SEXP rnng_set_promise_context(SEXP, SEXP);
349349
SEXP rnng_signal_thread_create(SEXP, SEXP);
350350
SEXP rnng_sleep(SEXP);
351-
SEXP rnng_socket_lock(SEXP, SEXP);
352-
SEXP rnng_socket_unlock(SEXP);
353351
SEXP rnng_stats_get(SEXP, SEXP);
354352
SEXP rnng_status_code(SEXP);
355353
SEXP rnng_stream_close(SEXP);

src/sync.c

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -109,24 +109,6 @@ void pipe_cb_signal(nng_pipe p, nng_pipe_ev ev, void *arg) {
109109

110110
}
111111

112-
static void pipe_cb_dropcon(nng_pipe p, nng_pipe_ev ev, void *arg) {
113-
114-
if (arg != NULL) {
115-
nano_cv *ncv = (nano_cv *) arg;
116-
nng_mtx *mtx = ncv->mtx;
117-
int cond;
118-
nng_mtx_lock(mtx);
119-
if ((cond = ncv->condition % 2))
120-
ncv->condition--;
121-
nng_mtx_unlock(mtx);
122-
if (cond)
123-
nng_pipe_close(p);
124-
} else {
125-
nng_pipe_close(p);
126-
}
127-
128-
}
129-
130112
static void pipe_cb_monitor(nng_pipe p, nng_pipe_ev ev, void *arg) {
131113

132114
nano_monitor *monitor = (nano_monitor *) arg;
@@ -564,44 +546,6 @@ SEXP rnng_pipe_notify(SEXP socket, SEXP cv, SEXP add, SEXP remove, SEXP flag) {
564546

565547
}
566548

567-
SEXP rnng_socket_lock(SEXP socket, SEXP cv) {
568-
569-
if (NANO_PTR_CHECK(socket, nano_SocketSymbol))
570-
Rf_error("'socket' is not a valid Socket");
571-
nng_socket *sock = (nng_socket *) NANO_PTR(socket);
572-
573-
int xc;
574-
if (cv != R_NilValue) {
575-
if (NANO_PTR_CHECK(cv, nano_CvSymbol))
576-
Rf_error("'cv' is not a valid Condition Variable");
577-
nano_cv *ncv = (nano_cv *) NANO_PTR(cv);
578-
xc = nng_pipe_notify(*sock, NNG_PIPE_EV_ADD_PRE, pipe_cb_dropcon, ncv);
579-
} else {
580-
xc = nng_pipe_notify(*sock, NNG_PIPE_EV_ADD_PRE, pipe_cb_dropcon, NULL);
581-
}
582-
583-
if (xc)
584-
ERROR_OUT(xc);
585-
586-
return nano_success;
587-
588-
}
589-
590-
SEXP rnng_socket_unlock(SEXP socket) {
591-
592-
if (NANO_PTR_CHECK(socket, nano_SocketSymbol))
593-
Rf_error("'socket' is not a valid Socket");
594-
595-
nng_socket *sock = (nng_socket *) NANO_PTR(socket);
596-
597-
const int xc = nng_pipe_notify(*sock, NNG_PIPE_EV_ADD_PRE, NULL, NULL);
598-
if (xc)
599-
ERROR_OUT(xc);
600-
601-
return nano_success;
602-
603-
}
604-
605549
// monitors --------------------------------------------------------------------
606550

607551
SEXP rnng_monitor_create(SEXP socket, SEXP cv) {

tests/tests.R

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -514,28 +514,6 @@ is_nano(s) && {
514514
test_type("integer", close(s))
515515
}
516516

517-
test_class("nano", s <- socket("bus", listen = "inproc://nanolock"))
518-
test_class("nano", s1 <- socket("bus", dial = "inproc://nanolock"))
519-
test_zero(lock(s))
520-
test_class("nano", s2 <- socket("bus", dial = "inproc://nanolock"))
521-
test_class("sendAio", send_aio(s, "test"))
522-
test_notnull(recv(s1, block = 500))
523-
test_class("errorValue", recv(s2))
524-
test_zero(unlock(s))
525-
test_zero(pipe_notify(s, cv = cv, add = TRUE, remove = TRUE))
526-
test_zero(lock(s, cv = cv))
527-
test_class("nano", s3 <- socket("bus", dial = "inproc://nanolock"))
528-
test_zero(send(s, "test", block = 500))
529-
test_notnull(recv(s3, block = 500))
530-
test_error(unlock(cv), "valid Socket")
531-
test_error(lock(cv), "valid Socket")
532-
test_error(lock(s, cv = s), "valid Condition Variable")
533-
test_zero(pipe_notify(s, cv = NULL, add = TRUE, remove = TRUE))
534-
test_zero(close(s))
535-
test_zero(close(s1))
536-
test_zero(close(s2))
537-
test_zero(close(s3))
538-
539517
test_equal(nanonext:::.DollarNames.ncurlAio(NULL, "sta"), "status")
540518
test_equal(nanonext:::.DollarNames.recvAio(NULL, "dat"), "data")
541519
test_equal(nanonext:::.DollarNames.sendAio(NULL, "r"), "result")

0 commit comments

Comments
 (0)