c3d.thread

the thread module is used for multitasking and sharing data across "channels" IMPORTANT: you can use the threaderror callback for handling errors

new_thread(...)creates a new thread object
new_channel()creates a new channel object without a set name
get_channel(name)returns a channel object for a given name.
threadthe thread object
channelthe channel object.
new_thread(...)Source

creates a new thread object

Parameters

  1. code string the code to create the thread from in a string form

Or

  1. path string the path to the file to load the code into the thread from
new_channel()Source

creates a new channel object without a set name

Returns

  1. channel the finished channel object
get_channel(name)Source

returns a channel object for a given name. makes one if it doesnt exist.

Parameters

  1. name string the name of the channel

Returns

  1. channel the channel object
threadSource

the thread object

get_error()if the thread happened to error this returns the error message
is_running()checks if the thread is currently running
start()starts the execution of this thread
wait()waits until the thread finishes execution
get_error()Source

if the thread happened to error this returns the error message

Returns

  1. any msg thread error message
is_running()Source

checks if the thread is currently running

Returns

  1. boolean true if thread is running
start()Source

starts the execution of this thread

wait()Source

waits until the thread finishes execution

channelSource

the channel object. a channel is basically a queue which you can add stuff into to share across your program, the values in the queue also get ids asigned

clear()completely clears the data queue of the channel
demand(timeout)returns a value from the queue.
get_count()returns the amount of things stored in the queue
has_read(ID)checks if a specific value in the queue has been read already
peek()reads a value from the queue without removing it
pop()removes a value from the queue and returns it
push(value)adds a value to the queue of the channel
supply(value, timeout)adds a value to the queue of the channel and waits for that value to be read (pop'ed) or for the timeout to go off
clear()Source

completely clears the data queue of the channel

demand(timeout)Source

returns a value from the queue. if there isnt one it waits for one or for a timeout to happen

Parameters

  1. timeout number the maximum time to wait for data in the queue

Returns

  1. any the data removed from the queue
get_count()Source

returns the amount of things stored in the queue

Returns

  1. number number of things in the queue
has_read(ID)Source

checks if a specific value in the queue has been read already

Parameters

  1. ID string the queue ID of the value

Returns

  1. boolean whether the value has been read yet
peek()Source

reads a value from the queue without removing it

Returns

  1. any data read from the queue
pop()Source

removes a value from the queue and returns it

Returns

  1. any data remove from the queue
push(value)Source

adds a value to the queue of the channel

Parameters

  1. value any the value to store in the queue

Returns

  1. string the ID of this value in the queue
supply(value, timeout)Source

adds a value to the queue of the channel and waits for that value to be read (pop'ed) or for the timeout to go off

Parameters

  1. value any the value to store in the queue
  2. timeout number the timeout to set for this supply

Returns

  1. boolean whether the timeout has gone off