Print this page
joyent/v8plus#7 v8plus should not hold the event loop open forever


 167  * error occurs, NULL is returned and _v8plus_errno set accordingly.  The
 168  * results of calling a method implemented in C via this interface are
 169  * undefined.
 170  *
 171  * These methods can be used in concert with JS code to emit events
 172  * asynchronously; see the documentation.
 173  *
 174  * Note: As JavaScript functions must be called from the event loop thread,
 175  * v8plus_method_call() contains logic to determine whether we are in the
 176  * correct context or not.  If we are running on some other thread we will
 177  * queue the request and sleep, waiting for the event loop thread to make the
 178  * call.  In the simple case, where we are already in the correct thread,
 179  * we make the call directly.  v8plus_method_call_direct() assumes we are
 180  * on the correct thread and always makes the call directly.
 181  */
 182 extern nvlist_t *v8plus_method_call(void *, const char *, const nvlist_t *);
 183 extern nvlist_t *v8plus_method_call_direct(void *, const char *,
 184     const nvlist_t *);
 185 
 186 /*
















 187  * These methods are analogous to strerror(3c) and similar functions; they
 188  * translate among error names, codes, and default messages.  There is
 189  * normally little need for these functions in C methods, as everything
 190  * necessary to construct a JavaScript exception is done by v8+, but these
 191  * may be useful in the construction of supplementary exception decorations
 192  * for debugging purposes.
 193  */
 194 extern const char *v8plus_strerror(v8plus_errno_t);
 195 extern const char *v8plus_errname(v8plus_errno_t);
 196 extern const char *v8plus_excptype(v8plus_errno_t);
 197 
 198 /*
 199  * Provided by C code.  See README.md.
 200  */
 201 extern const v8plus_c_ctor_f v8plus_ctor;
 202 extern const v8plus_c_dtor_f v8plus_dtor;
 203 extern const char *v8plus_js_factory_name;
 204 extern const char *v8plus_js_class_name;
 205 extern const v8plus_method_descr_t v8plus_methods[];
 206 extern const uint_t v8plus_method_count;


 167  * error occurs, NULL is returned and _v8plus_errno set accordingly.  The
 168  * results of calling a method implemented in C via this interface are
 169  * undefined.
 170  *
 171  * These methods can be used in concert with JS code to emit events
 172  * asynchronously; see the documentation.
 173  *
 174  * Note: As JavaScript functions must be called from the event loop thread,
 175  * v8plus_method_call() contains logic to determine whether we are in the
 176  * correct context or not.  If we are running on some other thread we will
 177  * queue the request and sleep, waiting for the event loop thread to make the
 178  * call.  In the simple case, where we are already in the correct thread,
 179  * we make the call directly.  v8plus_method_call_direct() assumes we are
 180  * on the correct thread and always makes the call directly.
 181  */
 182 extern nvlist_t *v8plus_method_call(void *, const char *, const nvlist_t *);
 183 extern nvlist_t *v8plus_method_call_direct(void *, const char *,
 184     const nvlist_t *);
 185 
 186 /*
 187  * These functions allow the consumer to hold the V8 event loop open for
 188  * potential input from other threads.  If your process blocks in another
 189  * thread, e.g. an event subscription thread, you must signal to v8plus
 190  * that the event loop should remain active.  Calls to v8plus_eventloop_hold()
 191  * and v8plus_eventloop_rele() should be balanced.  It is safe to call
 192  * v8plus_eventloop_rele() from outside the event loop thread.
 193  *
 194  * Note: Holds obtained via v8plus_obj_hold() and v8plus_jsfunc_hold() will
 195  * also automatically hold the event loop, removing the need to use this
 196  * interface explicitly.
 197  */
 198 extern void v8plus_eventloop_hold(void);
 199 extern void v8plus_eventloop_rele(void);
 200 extern void v8plus_eventloop_rele_direct(void);
 201 
 202 /*
 203  * These methods are analogous to strerror(3c) and similar functions; they
 204  * translate among error names, codes, and default messages.  There is
 205  * normally little need for these functions in C methods, as everything
 206  * necessary to construct a JavaScript exception is done by v8+, but these
 207  * may be useful in the construction of supplementary exception decorations
 208  * for debugging purposes.
 209  */
 210 extern const char *v8plus_strerror(v8plus_errno_t);
 211 extern const char *v8plus_errname(v8plus_errno_t);
 212 extern const char *v8plus_excptype(v8plus_errno_t);
 213 
 214 /*
 215  * Provided by C code.  See README.md.
 216  */
 217 extern const v8plus_c_ctor_f v8plus_ctor;
 218 extern const v8plus_c_dtor_f v8plus_dtor;
 219 extern const char *v8plus_js_factory_name;
 220 extern const char *v8plus_js_class_name;
 221 extern const v8plus_method_descr_t v8plus_methods[];
 222 extern const uint_t v8plus_method_count;