Class Threading[in Threading]

Access to static method that can be used to access threading functionalities.

class Threading

more...

Summary

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.

Detailed description

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.

Methods

getCurrent()

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.

getCurrentID()

Returns the current thread ID.

Threading.getCurrentID( )

Returns:A numeric ID uniquely identifying the current thread.

sameThread()

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.

start()

Starts a new thread and instructs it to execute the given callable item.

Threading.start( callable )

callableA Falcon callable item.
Raises:
ThreadErrorif the given object is not callable.

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] )

vwait()

Wait for one or more synchronization strucures to become available.

Threading.vwait( structArray, [waitTime] )

structArrayArray of structures to wait for
waitTimeMaximum timeout in seconds and fractions.
Returns: nil if timeout expires, an ID in the structArray or the acquired structure.
Raises:
InterrutpedErrorin case the thread receives a stop request.

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()

Wait for one or more synchronization strucures to become available.

Threading.wait( ..., [waitTime] )

...One or more synchronization structure to wait for.
waitTimeMaximum timeout in seconds and fractions.
Returns:nil if timeout expires, or the acquired item on success.
Raises:
InterrutpedErrorin case the thread receives a stop request.

This method waits for one of the structures in the given parameters to become acquireable, and acquires it before returning.


Made with faldoc 2.2.1