Collection

Utility library for manually interacting with ImgScal's concurrency system.


Source: pkg/lua/lib/collection.go | Import: collection

Functions


task

task(name) -> int<collection.TASK>

This creates an item in the task collection. This is a generic collection for any concurrency needs.

Arguments

  • name string
Return Values

  • int<collection.TASK>
reference

reference(type, id) -> id

This creates a new task queue that references the same data, this does not ensure thread safety. The reference may also get out of sync if the original item is overridden.

Arguments

  • type int<collection.Type
  • id int<collection.Type.* - An ID from the same collection as the above type.
Return Values

  • int<collection.Type.* - ID for a new collection item from the above id.
schedule

schedule(type, id, func)

Schedules a lua func to be called from the queue.

Arguments

  • type int<collection.Type>
  • id int<collection.Type.*> - An ID from the same collection as the above type.
  • func function()
wait

wait(type, id)

@blocking
Arguments

  • type int<collection.Type>
  • id int<collection.Type.*> - An ID from the same collection as the above type.
wait_all

wait_all(type)

@blocking
Arguments

  • type int<collection.Type>
wait_extensive

wait_extensive()

@blocking

This waits for all items across all collections to sync. Realistically, shouldn't be used.

collect

collect(type, id)

Items are collected automatically at the end of execution, but this can be used to collect early in workflows that create a large amount of items. This is important for collections that open files, as they are only closed when collected.

Arguments

  • type int<collection.Type>
  • id int<collection.Type.*> - An ID from the same collection as the above type.
exists

exists(type, id) -> bool

Note that this is non-blocking, and can return true for items that get collected soon after.

Arguments

  • type int<collection.Type>
  • id int<collection.Type.*> - An ID from the same collection as the above type.
Return Values

  • bool - If the item exists, and has not been collected.
log

log(type, id, msg)

Arguments

  • type int<collection.Type>
  • id int<collection.Type.*> - An ID from the same collection as the above type.
  • msg string
warn

warn(type, id, msg)

Arguments

  • type int<collection.Type>
  • id int<collection.Type.*> - An ID from the same collection as the above type.
  • msg string
panic

panic(type, id, msg)

@blocking
Arguments

  • type int<collection.Type>
  • id int<collection.Type.*> - An ID from the same collection as the above type.
  • msg string

Constants


Type
  • TASK
  • IMAGE
  • CONTEXT
  • QR
Crate
  • CRATE_WINDOW
  • CRATE_REF
  • CRATE_GAMEMAKER
  • CRATE_TEA
  • CRATE_LIPGLOSS
  • CRATE_CACHEDIMAGE
  • CRATE_SHADER