Access to static method that can be used to access threading functionalities.
class Threading
getCurrent() | Returns a Thread object built on the current system thread. |
getCurrentID() | Returns the current thread ID. |
sameThread() | Returns true if the given thread refers to the running system thread. |
start() | Starts a new thread and instructs it to execute the given callable item. |
vwait() | Wait for one or more synchronization strucures to become available. |
wait() | Wait for one or more synchronization strucures to become available. |
class Threading
Access to static method that can be used to access threading functionalities.
This class offers a namespace for generic methods provided by the Threading module. The mehods in this class are all static and can be directly called by items not derived from the Thread class to gain access to multithread functionalities.
Returns a Thread object built on the current system thread.
Threading.getCurrent( )
Returns: | A new instance of Thread. |
This method creates an instance of the Thread class referencing the current system thread. The returned object can then be shared, sent to other threads or used directly to control thraead execution.
Returns the current thread ID.
Threading.getCurrentID( )
Returns: | A numeric ID uniquely identifying the current thread. |
Returns true if the given thread refers to the running system thread.
Threading.sameThread( thread )
thread | Instance of the Thread class to be compared. |
Returns: | True if thread is referencing the currently running thread. |
Starts a new thread and instructs it to execute the given callable item.
Threading.start( callable )
callable | A Falcon callable item. | ||
Raises: |
|
This method works as Thread.run, but instead requiring a Thread class instance (or an instance of a derived class), it can start execution of an arbitrary symbol, including a method of a totally unrelated class.
In example:
function thread_a( sync, data ) ... end class MyClass function thread_b( sync ) ... end end ... // sync and data are shareable structures Threading.start( .[thread_a sync data] ) myInst = MyClass() Threading.start( .[ myInst.thread_b sync data] )
Wait for one or more synchronization strucures to become available.
Threading.vwait( structArray, [waitTime] )
structArray | Array of structures to wait for | ||
waitTime | Maximum timeout in seconds and fractions. | ||
Returns: | nil if timeout expires, an ID in the structArray or the acquired structure. | ||
Raises: |
|
This method waits for one of the structures in the given structArray to become acquireable, and acquires it before returning.
This works exactly as Threading.wait, but, on success, the method returns the ID of the acquired item in structArray rather than the object itself. In this way, it is possible to rotate or change the list of items on which to wait for at each call.
Wait for one or more synchronization strucures to become available.
Threading.wait( ..., [waitTime] )
... | One or more synchronization structure to wait for. | ||
waitTime | Maximum timeout in seconds and fractions. | ||
Returns: | nil if timeout expires, or the acquired item on success. | ||
Raises: |
|
This method waits for one of the structures in the given parameters to become acquireable, and acquires it before returning.