Skip to content

Commit 130081a

Browse files
mrmbernardisaghul
authored andcommitted
Added JS_GetPendingJobContext
1 parent fa2f060 commit 130081a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

quickjs.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2135,6 +2135,14 @@ bool JS_IsJobPending(JSRuntime *rt)
21352135
return !list_empty(&rt->job_list);
21362136
}
21372137

2138+
JSContext *JS_GetPendingJobContext(JSRuntime *rt)
2139+
{
2140+
if (JS_IsJobPending(rt)) {
2141+
return list_entry(rt->job_list.next, JSJobEntry, link)->ctx;
2142+
}
2143+
return NULL;
2144+
}
2145+
21382146
/* return < 0 if exception, 0 if no job pending, 1 if a job was
21392147
executed successfully. the context of the job is stored in '*pctx' */
21402148
int JS_ExecutePendingJob(JSRuntime *rt, JSContext **pctx)

quickjs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,7 @@ JS_EXTERN int JS_EnqueueJob(JSContext *ctx, JSJobFunc *job_func,
12071207
int argc, JSValueConst *argv);
12081208

12091209
JS_EXTERN bool JS_IsJobPending(JSRuntime *rt);
1210+
JS_EXTERN JSContext *JS_GetPendingJobContext(JSRuntime *rt);
12101211
JS_EXTERN int JS_ExecutePendingJob(JSRuntime *rt, JSContext **pctx);
12111212

12121213
/* Structure to retrieve (de)serialized SharedArrayBuffer objects. */

0 commit comments

Comments
 (0)