Update to address review comments in PR #1105
This commit is contained in:
parent
4f8f192cbe
commit
9977b13bcd
|
@ -449,7 +449,7 @@ static int node_compile( lua_State* L )
|
|||
return 0;
|
||||
}
|
||||
|
||||
// Task callback handler for node.tasknow()
|
||||
// Task callback handler for node.task.post()
|
||||
static task_handle_t do_node_task_handle;
|
||||
static void do_node_task (task_param_t task_fn_ref, uint8_t prio)
|
||||
{
|
||||
|
@ -461,7 +461,7 @@ static void do_node_task (task_param_t task_fn_ref, uint8_t prio)
|
|||
lua_call(L, 1, 0);
|
||||
}
|
||||
|
||||
// Lua: node.tasknow(task_cb)) -- schedule a task for execution next
|
||||
// Lua: node.task.post([priority],task_cb) -- schedule a task for execution next
|
||||
static int node_task_post( lua_State* L )
|
||||
{
|
||||
int n = 1, Ltype = lua_type(L, 1);
|
||||
|
@ -479,7 +479,11 @@ static int node_task_post( lua_State* L )
|
|||
if (!do_node_task_handle) // bind the task handle to do_node_task on 1st call
|
||||
do_node_task_handle = task_get_id(do_node_task);
|
||||
|
||||
task_post(priority, do_node_task_handle, (task_param_t)task_fn_ref);
|
||||
if(!task_post(priority, do_node_task_handle, (task_param_t)task_fn_ref)) {
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, task_fn_ref);
|
||||
luaL_error(L, "Task queue overflow. Task not posted");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Lua: setcpufreq(mhz)
|
||||
|
|
|
@ -412,6 +412,8 @@ Enable a Lua callback or task to post another task request. Note that as per the
|
|||
example multiple tasks can be posted in any task, but the highest priority is
|
||||
always delivered first.
|
||||
|
||||
If the task queue is full then a queue full error is raised.
|
||||
|
||||
####Syntax
|
||||
`node.task.post([task_priority], function)`
|
||||
|
||||
|
|
Loading…
Reference in New Issue