clang-format the source. Not exactly how I want it, but automated is better than perfect.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4845 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
114
src/task.c
114
src/task.c
@ -235,8 +235,7 @@ static import_record_t** _tf_task_find_import(tf_task_t* task, taskid_t task_id,
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
import_record_t search =
|
||||
{
|
||||
import_record_t search = {
|
||||
._task = task_id,
|
||||
._export = export_id,
|
||||
};
|
||||
@ -583,8 +582,7 @@ static JSValue _invokeCatch(JSContext* context, JSValueConst this_val, int argc,
|
||||
static void _forward_promise(tf_task_t* from, tf_taskstub_t* to, promiseid_t promise, JSValue result)
|
||||
{
|
||||
// We're not going to serialize/deserialize a promise...
|
||||
JSValue data[] =
|
||||
{
|
||||
JSValue data[] = {
|
||||
JS_NewInt32(from->_context, tf_taskstub_get_id(to)),
|
||||
JS_NewInt32(from->_context, promise),
|
||||
};
|
||||
@ -744,13 +742,13 @@ exportid_t tf_task_export_function(tf_task_t* task, tf_taskstub_t* to, JSValue f
|
||||
if (!export)
|
||||
{
|
||||
int id = -1;
|
||||
do {
|
||||
do
|
||||
{
|
||||
id = task->_nextExport++;
|
||||
} while (_task_get_export(task, id));
|
||||
|
||||
export = tf_malloc(sizeof(export_record_t));
|
||||
*export = (export_record_t)
|
||||
{
|
||||
*export = (export_record_t) {
|
||||
._export_id = id,
|
||||
._taskid = tf_taskstub_get_id(to),
|
||||
._function = JS_DupValue(task->_context, function),
|
||||
@ -885,20 +883,13 @@ char* tf_task_get_debug(tf_task_t* task)
|
||||
if (task->_promise_stacks[i].cstack_count)
|
||||
{
|
||||
JSValue cstack = JS_NewArray(context);
|
||||
backtrace_t bt =
|
||||
{
|
||||
backtrace_t bt = {
|
||||
.context = context,
|
||||
.array = cstack,
|
||||
};
|
||||
for (int k = 0; k < task->_promise_stacks[i].cstack_count; k++)
|
||||
{
|
||||
backtrace_pcinfo(
|
||||
g_backtrace_state,
|
||||
(uintptr_t)task->_promise_stacks[i].cstack[k],
|
||||
_tf_backtrace_callback,
|
||||
_tf_backtrace_error,
|
||||
&bt);
|
||||
|
||||
backtrace_pcinfo(g_backtrace_state, (uintptr_t)task->_promise_stacks[i].cstack[k], _tf_backtrace_callback, _tf_backtrace_error, &bt);
|
||||
}
|
||||
JS_SetPropertyStr(context, entry, "cstack", cstack);
|
||||
}
|
||||
@ -971,20 +962,34 @@ static const char* _tf_task_get_message_type(tf_task_message_t type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case kResolvePromise: return "kResolvePromise";
|
||||
case kRejectPromise: return "kRejectPromise";
|
||||
case kInvokeExport: return "kInvokeExport";
|
||||
case kReleaseExport: return "kReleaseExport";
|
||||
case kReleaseImport: return "kReleaseImport";
|
||||
case kActivate: return "kActivate";
|
||||
case kExecute: return "kExecute";
|
||||
case kKill: return "kKill";
|
||||
case kSetImports: return "kSetImports";
|
||||
case kGetExports: return "kGetExports";
|
||||
case kLoadFile: return "kLoadFile";
|
||||
case kTaskError: return "kTaskError";
|
||||
case kTaskTrace: return "kTaskTrace";
|
||||
case kPrint: return "kPrint";
|
||||
case kResolvePromise:
|
||||
return "kResolvePromise";
|
||||
case kRejectPromise:
|
||||
return "kRejectPromise";
|
||||
case kInvokeExport:
|
||||
return "kInvokeExport";
|
||||
case kReleaseExport:
|
||||
return "kReleaseExport";
|
||||
case kReleaseImport:
|
||||
return "kReleaseImport";
|
||||
case kActivate:
|
||||
return "kActivate";
|
||||
case kExecute:
|
||||
return "kExecute";
|
||||
case kKill:
|
||||
return "kKill";
|
||||
case kSetImports:
|
||||
return "kSetImports";
|
||||
case kGetExports:
|
||||
return "kGetExports";
|
||||
case kLoadFile:
|
||||
return "kLoadFile";
|
||||
case kTaskError:
|
||||
return "kTaskError";
|
||||
case kTaskTrace:
|
||||
return "kTaskTrace";
|
||||
case kPrint:
|
||||
return "kPrint";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
@ -1005,7 +1010,8 @@ void tf_task_on_receive_packet(int packetType, const char* begin, size_t length,
|
||||
memcpy(&promise, begin, sizeof(promise));
|
||||
memcpy(&exportId, begin + sizeof(promise), sizeof(exportId));
|
||||
|
||||
JSValue result = _task_invokeExport_internal(from, to, exportId, begin + sizeof(promiseid_t) + sizeof(exportid_t), length - sizeof(promiseid_t) - sizeof(exportid_t));
|
||||
JSValue result =
|
||||
_task_invokeExport_internal(from, to, exportId, begin + sizeof(promiseid_t) + sizeof(exportid_t), length - sizeof(promiseid_t) - sizeof(exportid_t));
|
||||
if (JS_IsException(result))
|
||||
{
|
||||
_tf_task_sendPromiseReject(to, from, promise, result);
|
||||
@ -1296,12 +1302,12 @@ JSValue tf_task_allocate_promise(tf_task_t* task, promiseid_t* out_promise)
|
||||
JS_FreeValue(task->_context, error);
|
||||
|
||||
promiseid_t promiseId;
|
||||
do {
|
||||
do
|
||||
{
|
||||
promiseId = task->_nextPromise++;
|
||||
} while (_tf_task_find_promise(task, promiseId) || !promiseId);
|
||||
|
||||
promise_t promise =
|
||||
{
|
||||
promise_t promise = {
|
||||
.id = promiseId,
|
||||
.values = { JS_NULL, JS_NULL },
|
||||
.stack_hash = stack_hash,
|
||||
@ -1389,13 +1395,13 @@ static void _promise_release_for_task(tf_task_t* task, taskid_t task_id)
|
||||
taskid_t tf_task_allocate_task_id(tf_task_t* task, tf_taskstub_t* stub)
|
||||
{
|
||||
taskid_t id = 0;
|
||||
do {
|
||||
do
|
||||
{
|
||||
id = task->_nextTask++;
|
||||
} while (id == k_task_parent_id || _tf_task_get_stub(task, id));
|
||||
|
||||
task_child_node_t* node = tf_malloc(sizeof(task_child_node_t));
|
||||
*node = (task_child_node_t)
|
||||
{
|
||||
*node = (task_child_node_t) {
|
||||
.id = id,
|
||||
.stub = stub,
|
||||
.next = task->_children,
|
||||
@ -1410,9 +1416,7 @@ void tf_task_remove_child(tf_task_t* task, tf_taskstub_t* child)
|
||||
_import_record_release_for_task(task, tf_taskstub_get_id(child));
|
||||
_export_record_release_for_task(task, tf_taskstub_get_id(child));
|
||||
_promise_release_for_task(task, tf_taskstub_get_id(child));
|
||||
for (task_child_node_t** it = &task->_children;
|
||||
*it;
|
||||
it = &(*it)->next)
|
||||
for (task_child_node_t** it = &task->_children; *it; it = &(*it)->next)
|
||||
{
|
||||
if ((*it)->stub == child)
|
||||
{
|
||||
@ -1474,8 +1478,7 @@ static void _tf_task_trace_timer(uv_timer_t* timer)
|
||||
task->thread_percent = tf_ssb_get_average_thread_percent(task->_ssb);
|
||||
task->last_hrtime = hrtime;
|
||||
task->last_idle_time = idle_time;
|
||||
const char* k_names[] =
|
||||
{
|
||||
const char* k_names[] = {
|
||||
"child_tasks",
|
||||
"imports",
|
||||
"exports",
|
||||
@ -1483,8 +1486,7 @@ static void _tf_task_trace_timer(uv_timer_t* timer)
|
||||
"idle_percent",
|
||||
"thread_percent",
|
||||
};
|
||||
int64_t values[] =
|
||||
{
|
||||
int64_t values[] = {
|
||||
task->_child_count,
|
||||
task->_import_count,
|
||||
task->_export_count,
|
||||
@ -1608,8 +1610,7 @@ tf_task_t* tf_task_create()
|
||||
JS_SetModuleLoaderFunc(task->_runtime, NULL, _tf_task_module_loader, task);
|
||||
|
||||
JS_NewClassID(&_import_class_id);
|
||||
JSClassDef def =
|
||||
{
|
||||
JSClassDef def = {
|
||||
.class_name = "imported_function",
|
||||
.finalizer = _import_finalizer,
|
||||
.gc_mark = _import_mark_func,
|
||||
@ -1818,7 +1819,6 @@ void tf_task_destroy(tf_task_t* task)
|
||||
for (task_child_node_t* node = task->_children; node; node = node->next)
|
||||
{
|
||||
JS_FreeValue(task->_context, tf_taskstub_kill(node->stub));
|
||||
|
||||
}
|
||||
uv_run(&task->_loop, UV_RUN_ONCE);
|
||||
}
|
||||
@ -1906,12 +1906,7 @@ void tf_task_destroy(tf_task_t* task)
|
||||
uv_signal_stop(&task->sig_int);
|
||||
uv_close((uv_handle_t*)&task->sig_int, _tf_task_on_handle_close);
|
||||
|
||||
while (task->trace_timer.data ||
|
||||
task->gc_timer.data ||
|
||||
task->idle.data ||
|
||||
task->prepare.data ||
|
||||
task->sig_term.data ||
|
||||
task->sig_int.data)
|
||||
while (task->trace_timer.data || task->gc_timer.data || task->idle.data || task->prepare.data || task->sig_term.data || task->sig_int.data)
|
||||
{
|
||||
uv_run(&task->_loop, UV_RUN_ONCE);
|
||||
}
|
||||
@ -1957,8 +1952,7 @@ JSValue tf_task_add_import(tf_task_t* task, taskid_t stub_id, exportid_t export_
|
||||
JSValue function = JS_NewObjectClass(task->_context, _import_class_id);
|
||||
import_record_t* import = tf_malloc(sizeof(import_record_t));
|
||||
JS_SetOpaque(function, import);
|
||||
*import = (import_record_t)
|
||||
{
|
||||
*import = (import_record_t) {
|
||||
._function = function,
|
||||
._export = export_id,
|
||||
._owner = task,
|
||||
@ -2102,12 +2096,7 @@ static void _tf_task_timeout_callback(uv_timer_t* handle)
|
||||
timeout_t* timeout = handle->data;
|
||||
tf_trace_begin(tf_task_get_trace(timeout->_task), "_tf_task_timeout_callback");
|
||||
JSContext* context = tf_task_get_context(timeout->_task);
|
||||
JSValue result = JS_Call(
|
||||
context,
|
||||
timeout->_callback,
|
||||
JS_NULL,
|
||||
0,
|
||||
NULL);
|
||||
JSValue result = JS_Call(context, timeout->_callback, JS_NULL, 0, NULL);
|
||||
tf_util_report_error(context, result);
|
||||
JS_FreeValue(context, result);
|
||||
JS_FreeValue(context, timeout->_callback);
|
||||
@ -2121,8 +2110,7 @@ static JSValue _tf_task_setTimeout(JSContext* context, JSValueConst this_val, in
|
||||
tf_task_t* task = JS_GetContextOpaque(context);
|
||||
|
||||
timeout_t* timeout = tf_malloc(sizeof(timeout_t));
|
||||
*timeout = (timeout_t)
|
||||
{
|
||||
*timeout = (timeout_t) {
|
||||
._task = task,
|
||||
._callback = JS_DupValue(context, argv[0]),
|
||||
._timer = { .data = timeout },
|
||||
|
Reference in New Issue
Block a user