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

Split Close
Expand all
Collapse all
          --- old/./v8plus_glue.h
          +++ new/./v8plus_glue.h
↓ open down ↓ 176 lines elided ↑ open up ↑
 177  177   * queue the request and sleep, waiting for the event loop thread to make the
 178  178   * call.  In the simple case, where we are already in the correct thread,
 179  179   * we make the call directly.  v8plus_method_call_direct() assumes we are
 180  180   * on the correct thread and always makes the call directly.
 181  181   */
 182  182  extern nvlist_t *v8plus_method_call(void *, const char *, const nvlist_t *);
 183  183  extern nvlist_t *v8plus_method_call_direct(void *, const char *,
 184  184      const nvlist_t *);
 185  185  
 186  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 +/*
 187  203   * These methods are analogous to strerror(3c) and similar functions; they
 188  204   * translate among error names, codes, and default messages.  There is
 189  205   * normally little need for these functions in C methods, as everything
 190  206   * necessary to construct a JavaScript exception is done by v8+, but these
 191  207   * may be useful in the construction of supplementary exception decorations
 192  208   * for debugging purposes.
 193  209   */
 194  210  extern const char *v8plus_strerror(v8plus_errno_t);
 195  211  extern const char *v8plus_errname(v8plus_errno_t);
 196  212  extern const char *v8plus_excptype(v8plus_errno_t);
↓ open down ↓ 24 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX