Skip to content

Commit a1deb15

Browse files
committed
revert c level developer interfaces for now
1 parent 84d61ac commit a1deb15

File tree

10 files changed

+3
-107
lines changed

10 files changed

+3
-107
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: nanonext
22
Type: Package
33
Title: NNG (Nanomsg Next Gen) Lightweight Messaging Library
4-
Version: 1.3.0.9003
4+
Version: 1.3.0.9004
55
Description: R binding for NNG (Nanomsg Next Gen), a successor to ZeroMQ. NNG is
66
a socket library implementing 'Scalability Protocols', a reliable,
77
high-performance standard for common communications patterns including

NAMESPACE

-1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,5 @@ export(until)
107107
export(until_)
108108
export(wait)
109109
export(wait_)
110-
export(with_lock)
111110
export(write_cert)
112111
useDynLib(nanonext, .registration = TRUE)

NEWS.md

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
# nanonext 1.3.0.9003 (development)
2-
3-
#### New Features
4-
5-
* Adds `with_lock()` to evaluate an expression while holding a mutex lock to prevent concurrent access by another thread which also requires the lock.
6-
* Exports the following C level callables for developers:
7-
- `rnng_thread_create()` which creates a thread running a C function with signature `void (*)(void *)` that takes a single `(void *)` argument, returning an external pointer to the thread.
8-
- `rnng_cv_lock()` which locks the mutex internal to a 'conditionVariable' (safe to use from another thread).
9-
- `rnng_cv_unlock()` which unlocks the mutex internal to a 'conditionVariable' (safe to use from another thread).
1+
# nanonext 1.3.0.9004 (development)
102

113
#### Updates
124

R/sync.R

-27
Original file line numberDiff line numberDiff line change
@@ -334,30 +334,3 @@ unlock <- function(socket) invisible(.Call(rnng_socket_unlock, socket))
334334
#' @export
335335
#'
336336
.online <- function(sock) .Call(rnng_read_online, sock)
337-
338-
#' With Lock
339-
#'
340-
#' Evaluate an expression whilst holding a mutex lock internal to a
341-
#' \sQuote{conditionVariable}. The purpose of this function is to prevent
342-
#' access to objects guarded by the same lock from another thread.
343-
#'
344-
#' Do not attempt to call any function using the conditionVariable \sQuote{cv}
345-
#' in \sQuote{expr} otherwise you will create a deadlock.
346-
#'
347-
#' @inheritParams wait
348-
#' @param expr an expression to evaluate under lock.
349-
#'
350-
#' @return The return value of \sQuote{expr}.
351-
#'
352-
#' @examples
353-
#' cv <- cv()
354-
#' with_lock(cv, "hello")
355-
#'
356-
#' @export
357-
#'
358-
with_lock <- function(cv, expr) {
359-
.Call(rnng_cv_assert, cv)
360-
.Call(rnng_cv_lock, cv)
361-
on.exit(.Call(rnng_cv_unlock, cv))
362-
expr
363-
}

man/with_lock.Rd

-30
This file was deleted.

src/init.c

-6
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,8 @@ static const R_CallMethodDef callMethods[] = {
133133
{"rnng_ctx_create", (DL_FUNC) &rnng_ctx_create, 1},
134134
{"rnng_ctx_open", (DL_FUNC) &rnng_ctx_open, 1},
135135
{"rnng_cv_alloc", (DL_FUNC) &rnng_cv_alloc, 0},
136-
{"rnng_cv_assert", (DL_FUNC) &rnng_cv_assert, 1},
137-
{"rnng_cv_lock", (DL_FUNC) &rnng_cv_lock, 1},
138136
{"rnng_cv_reset", (DL_FUNC) &rnng_cv_reset, 1},
139137
{"rnng_cv_signal", (DL_FUNC) &rnng_cv_signal, 1},
140-
{"rnng_cv_unlock", (DL_FUNC) &rnng_cv_unlock, 1},
141138
{"rnng_cv_until", (DL_FUNC) &rnng_cv_until, 2},
142139
{"rnng_cv_until_safe", (DL_FUNC) &rnng_cv_until_safe, 2},
143140
{"rnng_cv_value", (DL_FUNC) &rnng_cv_value, 1},
@@ -209,9 +206,6 @@ void attribute_visible R_init_nanonext(DllInfo* dll) {
209206
R_registerRoutines(dll, NULL, callMethods, NULL, externalMethods);
210207
R_useDynamicSymbols(dll, FALSE);
211208
R_forceSymbols(dll, TRUE);
212-
R_RegisterCCallable("nanonext", "rnng_thread_create", (DL_FUNC) &rnng_thread_create);
213-
R_RegisterCCallable("nanonext", "rnng_cv_lock", (DL_FUNC) &rnng_cv_lock);
214-
R_RegisterCCallable("nanonext", "rnng_cv_unlock", (DL_FUNC) &rnng_cv_unlock);
215209
}
216210

217211
// # nocov start

src/nanonext.h

-5
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,8 @@ SEXP rnng_ctx_close(SEXP);
312312
SEXP rnng_ctx_create(SEXP);
313313
SEXP rnng_ctx_open(SEXP);
314314
SEXP rnng_cv_alloc(void);
315-
SEXP rnng_cv_assert(SEXP);
316-
SEXP rnng_cv_lock(SEXP);
317315
SEXP rnng_cv_reset(SEXP);
318316
SEXP rnng_cv_signal(SEXP);
319-
SEXP rnng_cv_unlock(SEXP);
320317
SEXP rnng_cv_until(SEXP, SEXP);
321318
SEXP rnng_cv_until_safe(SEXP, SEXP);
322319
SEXP rnng_cv_value(SEXP);
@@ -376,6 +373,4 @@ SEXP rnng_version(void);
376373
SEXP rnng_wait_thread_create(SEXP);
377374
SEXP rnng_write_cert(SEXP, SEXP, SEXP);
378375

379-
SEXP rnng_thread_create(void (*)(void *), void *);
380-
381376
#endif

src/sync.c

-25
Original file line numberDiff line numberDiff line change
@@ -398,31 +398,6 @@ SEXP rnng_cv_signal(SEXP cvar) {
398398

399399
}
400400

401-
SEXP rnng_cv_assert(SEXP cvar) {
402-
403-
if (NANO_TAG(cvar) != nano_CvSymbol)
404-
Rf_error("'cv' is not a valid Condition Variable");
405-
406-
return nano_success;
407-
408-
}
409-
410-
SEXP rnng_cv_lock(SEXP cvar) {
411-
412-
nng_mtx_lock(((nano_cv *) NANO_PTR(cvar))->mtx);
413-
414-
return nano_success;
415-
416-
}
417-
418-
SEXP rnng_cv_unlock(SEXP cvar) {
419-
420-
nng_mtx_unlock(((nano_cv *) NANO_PTR(cvar))->mtx);
421-
422-
return nano_success;
423-
424-
}
425-
426401
// request ---------------------------------------------------------------------
427402

428403
SEXP rnng_request(SEXP con, SEXP data, SEXP sendmode, SEXP recvmode, SEXP timeout, SEXP cvar, SEXP clo) {

src/thread.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static void thread_finalizer(SEXP xptr) {
3333

3434
}
3535

36-
SEXP rnng_thread_create(void (*func)(void *), void *arg) {
36+
static SEXP rnng_thread_create(void (*func)(void *), void *arg) {
3737

3838
nng_thread *thr;
3939
int xc;

tests/tests.R

-2
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,6 @@ test_zero(close(s2))
525525
test_zero(close(s3))
526526

527527
test_type("externalptr", cv <- cv())
528-
test_equal(with_lock(cv, "hello"), "hello")
529-
test_error(with_lock("cv", "hello"), "valid Condition Variable")
530528
test_error(.dispatcher(host = "inproc://hostdisp", url = "inproc://disp/1", tls = ""), "not a valid TLS Configuration")
531529
test_type("externalptr", disp <- .dispatcher(host = "inproc://hostdisp", url = "inproc://disp/1", tls = NULL))
532530
test_zero(.online(disp))

0 commit comments

Comments
 (0)