Tilde Friends
Loading...
Searching...
No Matches
task.h
1#pragma once
2
12#include <stdbool.h>
13
14#include "quickjs.h"
15
17typedef struct uv_loop_s uv_loop_t;
18
20typedef int taskid_t;
22typedef int promiseid_t;
24typedef int exportid_t;
26typedef struct _tf_taskstub_t tf_taskstub_t;
28typedef struct _tf_task_t tf_task_t;
30typedef struct _tf_trace_t tf_trace_t;
32typedef struct _tf_ssb_t tf_ssb_t;
33
35static const taskid_t k_task_parent_id = 0;
36
39{
40 kResolvePromise,
41 kRejectPromise,
42 kInvokeExport,
43 kReleaseExport,
44 kReleaseImport,
45 kActivate,
46 kExecute,
47 kKill,
48 kSetImports,
49 kGetExports,
50 kLoadFile,
51 kTaskError,
52 kTaskTrace,
53 kPrint,
55
61
69
75void tf_task_set_ssb_network_key(tf_task_t* task, const char* network_key);
76
82void tf_task_set_db_path(tf_task_t* task, const char* path);
83
89void tf_task_set_zip_path(tf_task_t* task, const char* path);
90
96void tf_task_set_root_path(tf_task_t* task, const char* path);
97
104
111
118const char* tf_task_get_path_with_root(tf_task_t* task, const char* path);
119
125void tf_task_set_args(tf_task_t* task, const char* args);
126
133
140void tf_task_set_one_proc(tf_task_t* task, bool one_proc);
141
147
153
160int tf_task_execute(tf_task_t* task, const char* file);
161
167void tf_task_set_trusted(tf_task_t* task, bool trusted);
168
175
181
190
200JSValue tf_task_add_import(tf_task_t* task, taskid_t stub_id, exportid_t export_id);
201
208
215
222
229
235const char* tf_task_get_name(tf_task_t* task);
236
243void tf_task_print(tf_task_t* task, int argc, JSValueConst* argv);
244
251JSValue tf_task_allocate_promise(tf_task_t* task, promiseid_t* out_promise);
252
259void tf_task_reject_promise(tf_task_t* task, promiseid_t promise, JSValue error);
260
267void tf_task_resolve_promise(tf_task_t* task, promiseid_t promise, JSValue result);
268
278
286void tf_task_on_receive_packet(int packetType, const char* begin, size_t length, void* userData);
287
295
302
310bool tf_task_send_error_to_parent(tf_task_t* task, JSValue error);
311
319
325typedef void(tf_android_start_service_t)(int pipe_fd);
326
331
338
344
350
357
364
371void tf_task_visit_children(tf_task_t* task, void (*callback)(tf_task_t* task, tf_taskstub_t* stub, void* user_data), void* user_data);
372
380
struct JSContext JSContext
Definition api.js.h:10
struct _tf_task_t tf_task_t
Definition file.js.h:12
struct _tf_trace_t tf_trace_t
Definition http.h:27
struct uv_loop_s uv_loop_t
Definition http.h:30
struct _tf_ssb_t tf_ssb_t
Definition httpd.js.h:35
struct _tf_taskstub_t tf_taskstub_t
Definition serialize.h:15
int exportid_t
Definition task.h:24
void tf_task_set_db_path(tf_task_t *task, const char *path)
void tf_task_set_zip_path(tf_task_t *task, const char *path)
JSValue tf_task_allocate_promise(tf_task_t *task, promiseid_t *out_promise)
tf_taskstub_t * tf_task_get_stub(tf_task_t *task, taskid_t id)
void tf_task_set_root_path(tf_task_t *task, const char *path)
const char * tf_task_get_zip_path(tf_task_t *task)
tf_trace_t * tf_task_get_trace(tf_task_t *task)
_tf_task_message_t
Definition task.h:39
enum _tf_task_message_t tf_task_message_t
taskid_t tf_task_allocate_task_id(tf_task_t *task, tf_taskstub_t *stub)
void tf_task_configure_from_fd(tf_task_t *task, int fd)
int tf_task_execute(tf_task_t *task, const char *file)
void tf_task_visit_children(tf_task_t *task, void(*callback)(tf_task_t *task, tf_taskstub_t *stub, void *user_data), void *user_data)
void tf_task_run(tf_task_t *task)
const char * tf_task_get_name(tf_task_t *task)
char * tf_task_get_debug(tf_task_t *task)
void tf_task_reject_promise(tf_task_t *task, promiseid_t promise, JSValue error)
void tf_task_send_promise_message(tf_task_t *from, tf_taskstub_t *to, tf_task_message_t type, promiseid_t promise, JSValue payload)
tf_android_stop_service_t * tf_task_get_android_stop_service()
bool tf_task_is_shutting_down(tf_task_t *task)
bool tf_task_get_one_proc(tf_task_t *task)
int taskid_t
Definition task.h:20
void tf_task_activate(tf_task_t *task)
void tf_task_set_trusted(tf_task_t *task, bool trusted)
exportid_t tf_task_export_function(tf_task_t *task, tf_taskstub_t *to, JSValue function)
tf_ssb_t * tf_task_get_ssb(tf_task_t *task)
const char * tf_task_get_path_with_root(tf_task_t *task, const char *path)
JSValue tf_task_add_import(tf_task_t *task, taskid_t stub_id, exportid_t export_id)
void tf_task_set_ssb_network_key(tf_task_t *task, const char *network_key)
void tf_task_on_receive_packet(int packetType, const char *begin, size_t length, void *userData)
void tf_task_set_one_proc(tf_task_t *task, bool one_proc)
void tf_task_remove_child(tf_task_t *task, tf_taskstub_t *child)
bool tf_task_send_error_to_parent(tf_task_t *task, JSValue error)
void() tf_android_start_service_t(int pipe_fd)
Definition task.h:325
void tf_task_set_args(tf_task_t *task, const char *args)
tf_task_t * tf_task_get(JSContext *context)
int promiseid_t
Definition task.h:22
void() tf_android_stop_service_t()
Definition task.h:330
const char * tf_task_get_root_path(tf_task_t *task)
uv_loop_t * tf_task_get_loop(tf_task_t *task)
tf_android_start_service_t * tf_task_get_android_start_service()
void tf_task_set_android_service_callbacks(tf_android_start_service_t *start_service, tf_android_stop_service_t *stop_service)
JSContext * tf_task_get_context(tf_task_t *task)
void tf_task_destroy(tf_task_t *task)
void tf_task_check_jobs(tf_task_t *task)
tf_task_t * tf_task_create()
void tf_task_resolve_promise(tf_task_t *task, promiseid_t promise, JSValue result)
void tf_task_print(tf_task_t *task, int argc, JSValueConst *argv)