Parameter Type Required Description loop EventLoop✔ The EventLoop that the Lock belongs to. Creates a new instance of Lock
This is an object used to have exclusive access to shared resources.
If a task acquired it, no other task can acquire the object again until this one releases itReturns:
Type Description LockThe Lock object Table structure:
{ loop = loop, -- The EventLoop that the Lock belongs to tasks = {}, -- The Tasks objects that are waiting to acquire the Lock tasks_append = 0, -- The current tasks list "append" pointer tasks_give = 0, -- The current tasks list "give" pointer is_locked = false -- Whether the lock is set or not }
Returns a task that, when awaited, will block until the lock is acquired.
Returns:
Type Description TaskThe task
Releases the lock and wakes up the next task waiting to acquire it, if any.
Parameter Type Required Description loop EventLoop✔ The EventLoop that the Event belongs to. Creates a new instance of Event
This is an object that notifies other tasks when it is set.Returns:
Type Description EventThe Event object Table structure:
{ loop = loop, -- The EventLoop that the Event belongs to tasks = {}, -- The tasks that are waiting for the Event to be set tasks_index = 0, -- The tasks list pointer is_set = false -- Whether the event is set or not }
Return a task that, when awaited, will block until Event.is_set is true.
Returns:
Type Description TaskThe task
Sets the event and releases every Event:wait() task.
Clears (unset) the event, making every new Event:wait() task block again.