2.13.13Class Threading

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

Class Threading

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
getCurrentReturns a Thread object built on the current system thread.
getCurrentIDReturns the current thread ID.
sameThreadReturns true if the given thread refers to the running system thread.
startStarts a new thread and instructs it to execute the given callable item.
vwaitWait for one or more synchronization strucures to become available.
waitWait for one or more synchronization strucures to become available.

Methods

getCurrent

Returns a Thread object built on the current system thread.

Threading.getCurrent()
ReturnA 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()
ReturnA numeric ID uniquely identifying the current thread.

See also: 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.
ReturnTrue 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 )
callable A Falcon callable item.
Raise
ThreadError if 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] )
structArray Array of structures to wait for
waitTime Maximum timeout in seconds and fractions.
Returnnil if timeout expires, an ID in the structArray or the acquired structure.
Raise
InterrutpedError in 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.

See also: Thread.

wait

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.
Returnnil if timeout expires, or the acquired item on success.
Raise
InterrutpedError in 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.

See also: Thread.

Made with http://www.falconpl.org