Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, for more info) to build successfully.

Commits (1)
  • Deucе's avatar
    Add js.setImmediate(callback[, thisObj) · a1797cc6
    Deucе authored
    I haven't added a clearImmediate() because there's currently no way
    of manipulating the run queue, and I can't come up with a reason
    someone would actually need it.
......@@ -879,6 +879,52 @@ js_setInterval(JSContext *cx, uintN argc, jsval *arglist)
return JS_TRUE;
static JSBool
js_setImmediate(JSContext *cx, uintN argc, jsval *arglist)
jsval *argv=JS_ARGV(cx, arglist);
JSFunction *cbf;
JSObject *obj=JS_THIS_OBJECT(cx, arglist);
js_callback_t *cb;
struct js_runq_entry *rqe;
if (argc < 1) {
JS_ReportError(cx, "js.setImmediate() requires a callback");
return JS_FALSE;
cbf = JS_ValueToFunction(cx, argv[0]);
if (cbf == NULL) {
return JS_FALSE;
if (argc > 1) {
if (!JS_ValueToObject(cx, argv[1], &obj))
return JS_FALSE;
rqe = malloc(sizeof(*rqe));
if (rqe == NULL) {
JS_ReportError(cx, "error allocating %ul bytes", sizeof(*rqe));
return JS_FALSE;
rqe->func = cbf;
rqe->cx = obj;
JS_AddObjectRoot(cx, &rqe->cx);
rqe->next = NULL;
if (cb->rq_tail != NULL)
cb->rq_tail->next = rqe;
cb->rq_tail = rqe;
if (cb->rq_head == NULL)
cb->rq_head = rqe;
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
return JS_TRUE;
static JSBool
js_addEventListener(JSContext *cx, uintN argc, jsval *arglist)
......@@ -1438,6 +1484,10 @@ static jsSyncMethodSpec js_functions[] = {
,JSDOCSTR("Add all listeners of eventName to the runqueue. If obj is passed, specifies this in the callback (the js object is used otherwise).")
{"setImmediate", js_setImmediate, 1, JSTYPE_VOID, JSDOCSTR("callback[, thisObj]")
,JSDOCSTR("adds the callback to the end of the run queue, where it will be called after all pending events are processed")