@@ -20,15 +20,6 @@ static void session_finalizer(SEXP xptr) {
20
20
fsw_destroy_session (handle );
21
21
}
22
22
23
- void (* eln2 )(void (* )(void * ), void * , double , int ) = NULL ;
24
-
25
- static void load_later_safe (void * data ) {
26
- SEXP call , fn = (SEXP ) data ;
27
- PROTECT (call = Rf_lang2 (fn , Rf_mkString ("later" )));
28
- Rf_eval (call , R_GlobalEnv );
29
- UNPROTECT (1 );
30
- }
31
-
32
23
static void exec_later (void * data ) {
33
24
SEXP call , fn = (SEXP ) data ;
34
25
PROTECT (call = Rf_lcons (fn , R_NilValue ));
@@ -50,7 +41,7 @@ static void get_event_flag_name(const int flag, char *buf) {
50
41
}
51
42
52
43
static void process_events (fsw_cevent const * const events , const unsigned int event_num , void * data ) {
53
- if (data != R_NilValue && eln2 != NULL ) {
44
+ if (data != R_NilValue ) {
54
45
eln2 (exec_later , data , 0 , 0 );
55
46
} else {
56
47
char buf [8 ]; // large enough for subset of events handled by get_event_flag_name()
@@ -76,11 +67,6 @@ SEXP watcher_create(SEXP path, SEXP recursive, SEXP callback) {
76
67
77
68
const char * watch_path = CHAR (STRING_ELT (path , 0 ));
78
69
const int recurse = LOGICAL (recursive )[0 ];
79
- if (callback != R_NilValue ) {
80
- SEXPTYPE typ = TYPEOF (callback );
81
- if (typ != CLOSXP && typ != BUILTINSXP && typ != SPECIALSXP )
82
- Rf_error ("'callback' must be a function" );
83
- }
84
70
85
71
FSW_HANDLE handle = fsw_init_session (system_default_monitor_type );
86
72
if (handle == NULL ) {
@@ -121,15 +107,11 @@ SEXP watcher_create(SEXP path, SEXP recursive, SEXP callback) {
121
107
SEXP watcher_start_monitor (SEXP session ) {
122
108
123
109
FSW_HANDLE handle = (FSW_HANDLE ) R_ExternalPtrAddr (session );
110
+
124
111
pthread_t thr ;
125
112
pthread_attr_t attr ;
126
-
127
113
pthread_attr_init (& attr );
128
114
pthread_attr_setdetachstate (& attr , PTHREAD_CREATE_DETACHED );
129
-
130
- if (eln2 == NULL && R_ToplevelExec (load_later_safe , (void * ) Rf_install ("loadNamespace" ))) {
131
- eln2 = (void (* )(void (* )(void * ), void * , double , int )) R_GetCCallable ("later" , "execLaterNative2" );
132
- }
133
115
const int ret = pthread_create (& thr , & attr , & watcher_thread , handle );
134
116
pthread_attr_destroy (& attr );
135
117
0 commit comments