Skip to content

Commit

Permalink
optimize implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
shikokuchuo committed Jul 25, 2024
1 parent d36af2f commit e0614b5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/aio.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ SEXP rnng_aio_get_msg(SEXP env) {
sz = nng_msg_len(msg);
}

PROTECT(out = nano_decode(buf, sz, raio->mode, ATTRIB(aio)));
PROTECT(out = nano_decode(buf, sz, raio->mode, NANO_PROT(aio)));
Rf_defineVar(nano_ValueSymbol, out, env);
Rf_defineVar(nano_AioSymbol, R_NilValue, env);

Expand Down Expand Up @@ -584,7 +584,7 @@ SEXP rnng_recv_aio(SEXP con, SEXP mode, SEXP timeout, SEXP cvar, SEXP bytes, SEX

PROTECT(aio = R_MakeExternalPtr(raio, nano_AioSymbol, R_NilValue));
R_RegisterCFinalizerEx(aio, raio_finalizer, TRUE);
SET_ATTRIB(aio, NANO_PROT(con));
NANO_SET_PROT(aio, NANO_PROT(con));

} else if (ptrtag == nano_StreamSymbol) {

Expand Down
2 changes: 1 addition & 1 deletion src/sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ SEXP rnng_request(SEXP con, SEXP data, SEXP sendmode, SEXP recvmode, SEXP timeou

PROTECT(aio = R_MakeExternalPtr(raio, nano_AioSymbol, R_NilValue));
R_RegisterCFinalizerEx(aio, request_finalizer, TRUE);
SET_ATTRIB(aio, NANO_PROT(con));
NANO_SET_PROT(aio, NANO_PROT(con));

PROTECT(env = Rf_allocSExp(ENVSXP));
Rf_classgets(env, nano_reqAio);
Expand Down
4 changes: 0 additions & 4 deletions src/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ SEXP rnng_wait_thread_create(SEXP x) {
if (NANO_TAG(coreaio) != nano_AioSymbol)
return x;

PROTECT(coreaio);
nano_aio *aiop = (nano_aio *) NANO_PTR(coreaio);

nano_thread_aio *taio = R_Calloc(1, nano_thread_aio);
Expand All @@ -263,9 +262,7 @@ SEXP rnng_wait_thread_create(SEXP x) {
ncv->cv = cv;

SEXP xptr = R_MakeExternalPtr(taio, R_NilValue, R_NilValue);
NANO_SET_PROT(coreaio, xptr);
R_RegisterCFinalizerEx(xptr, thread_aio_finalizer, TRUE);
UNPROTECT(1);

nng_time time = nng_clock();

Expand Down Expand Up @@ -311,7 +308,6 @@ SEXP rnng_wait_thread_create(SEXP x) {
exitlevel1:
R_Free(ncv);
R_Free(taio);
UNPROTECT(1);
ERROR_OUT(xc);

} else if (typ == VECSXP) {
Expand Down

0 comments on commit e0614b5

Please sign in to comment.