Tilde Friends
task.h
1#pragma once
2
12#include <stdbool.h>
13
14#include "quickjs.h"
15
17typedef struct uv_loop_s uv_loop_t;
19typedef struct uv_timer_s uv_timer_t;
20
22typedef int taskid_t;
24typedef int promiseid_t;
26typedef int exportid_t;
28typedef struct _tf_taskstub_t tf_taskstub_t;
30typedef struct _tf_task_t tf_task_t;
32typedef struct _tf_trace_t tf_trace_t;
34typedef struct _tf_ssb_t tf_ssb_t;
35
37static const taskid_t k_task_parent_id = 0;
38
41{
42 kResolvePromise,
43 kRejectPromise,
44 kInvokeExport,
45 kReleaseExport,
46 kReleaseImport,
47 kActivate,
48 kExecute,
49 kKill,
50 kSetImports,
51 kGetExports,
52 kLoadFile,
53 kTaskError,
54 kTaskTrace,
55 kPrint,
57
63
71
77void tf_task_set_ssb_network_key(tf_task_t* task, const char* network_key);
78
84void tf_task_set_db_path(tf_task_t* task, const char* path);
85
91void tf_task_set_zip_path(tf_task_t* task, const char* path);
92
98void tf_task_set_root_path(tf_task_t* task, const char* path);
99
106
113
120const char* tf_task_get_path_with_root(tf_task_t* task, const char* path);
121
127void tf_task_set_args(tf_task_t* task, const char* args);
128
135
142void tf_task_set_one_proc(tf_task_t* task, bool one_proc);
143
149
155
162int tf_task_execute(tf_task_t* task, const char* file);
163
169void tf_task_set_trusted(tf_task_t* task, bool trusted);
170
177
183
192
202JSValue tf_task_add_import(tf_task_t* task, taskid_t stub_id, exportid_t export_id);
203
210
217
224
231
237const char* tf_task_get_name(tf_task_t* task);
238
245void tf_task_print(tf_task_t* task, int argc, JSValueConst* argv);
246
253JSValue tf_task_allocate_promise(tf_task_t* task, promiseid_t* out_promise);
254
261void tf_task_reject_promise(tf_task_t* task, promiseid_t promise, JSValue error);
262
269void tf_task_resolve_promise(tf_task_t* task, promiseid_t promise, JSValue result);
270
280
288void tf_task_on_receive_packet(int packetType, const char* begin, size_t length, void* userData);
289
297
304
312bool tf_task_send_error_to_parent(tf_task_t* task, JSValue error);
313
321
327typedef void(tf_android_start_service_t)(int pipe_fd);
328
333
340
346
352
359
366
struct JSContext JSContext
Definition: api.js.h:10
struct _tf_task_t tf_task_t
Definition: file.js.h:14
struct _tf_trace_t tf_trace_t
Definition: http.h:30
struct uv_loop_s uv_loop_t
Definition: http.h:33
struct _tf_ssb_t tf_ssb_t
Definition: httpd.js.h:38
struct _tf_taskstub_t tf_taskstub_t
Definition: serialize.h:15
int exportid_t
Definition: task.h:26
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)
void tf_task_set_root_path(tf_task_t *task, const char *path)
struct uv_timer_s uv_timer_t
Definition: task.h:19
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:41
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_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:22
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:327
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:24
void() tf_android_stop_service_t()
Definition: task.h:332
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)