Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrQueueBlocked = errors.New("queue currently blocked")
ErrQueueBlocked is returned when a new item should be added to the queue but it is currently blocked
Functions ¶
This section is empty.
Types ¶
type Loop ¶
type Loop interface { // Start starts the loop Start(context.Context) error // Schedule a new task to be executed inside the loop Schedule(Task) // ScheduleAndWait schedules a task on the loop and waits for it to finish ScheduleAndWait(Task) // Stop the loop Stop() // Wait for the loop to finish Wait() }
Loop is an async event loop for lua
type Options ¶
type Options struct { // InitVM is called with the new lua State before the event loop is initialized InitVM func(*lua.LState) error }
Options used when creating a new event loop
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue implements a job queue for the event loop
func (*Queue) Block ¶
func (q *Queue) Block()
Block the queue and deny any push action. Pop will still work
func (*Queue) Pop ¶
Pop returns the next task to execute from the queue or nil if the queue is empty
func (*Queue) PopWait ¶
PopWait returns the next job from the queue and will block until either the context is cancelled or a job becomes available. If the queue is empty and blocked (i.e. Block() has been called), PopWait will return immediately with ErrQueueBlocked. If the provided context is canceled ctx.Err() will be returned