Skip to Content
Skip to Content

Task

zune.task


A library to interact with the task scheduler.

Functions

cancel

Cancels a task, and resets thread.

cancel(thread: thread): ()

Parameters

  • thread: thread - The thread to cancel.

defer

Runs function or thread on end of scheduler frame.

defer(f: ((A...) -> R...) | thread, A...): thread

Parameters

  • f: ((A...) -> R...) | thread - The function to defer.
  • A... - The arguments to pass to the function.

delay

Runs function or thread after a certain amount of time.

delay(sec: number, f: ((A...) -> (R...)) | thread, A...): thread

Parameters

  • sec: number - The amount of time to delay.
  • f: ((A...) -> (R...)) | thread - The function to run after the delay.
  • A... - The arguments to pass to the function.

spawn

Runs function or thread immediately.

spawn(f: ((A...) -> (R...)) | thread, A...): thread

Parameters

  • f: ((A...) -> (R...)) | thread - The function to run immediately.
  • A... - The arguments to pass to the function.

wait

Yields and resumes current calling thread after a certain amount of time, returning the total time the sleep took.

wait(sec: number?): number

Parameters

  • sec: number? - The amount of time to sleep.

count

Counts the number of current tasks.

Optional kinds parameter to count a specific kind of task.

Kinds:

  • s to count sleeping tasks.
  • d to count deferred tasks.
  • w to count awaiting tasks. (zune backend)
  • t to count internal tasks. (zune backend)
count(): number count(kinds: string): ...number

Parameters

  • kinds: string? - The kinds of tasks to count. nil to count all kinds.
    • default: nil

Throws

  • Error
Last updated on