lubyk logo

Lubyk documentation

Thread

Thread garbage collection

As long as a thread is scheduled to run (active loop, listening for, it will be kept in memory.

Error handling

When an error occurs in a thread, the related coroutine dies. If the thread has a restart function set, this function is called with the thread's time reference and the scheduler. Here is the example used to restart the Timer thread in case of errors in the timeout function:

local restart_func
restart_func = function(at, sched)
  self.thread = Thread(self.cb, at + self.interval, sched)
  self.thread.restart = restart_func
end
self.thread.restart = restart_func

Error handling can be personalized by the thread by setting an error function.

.new (func, at, sched)

Create a new Thread object and insert it inside the currently running scheduler's event queue. The thread is retained in the scheduler as long as it is alive (function has not reached the end). If sched is provided, this scheduler will be used instead of using yield. If the yield call fails due to a C-call boundary, the default lens.sched scheduler will be used.

:kill ()

TODO MISSING DOCUMENTATION

:join ()

Running thread will wait for this thread to finish.

TODO

#killTODO MISSING DOCUMENTATION