Домой Классы Статические функции Перечисления (ENUM) Структуры (STRUCTURE)

{Thread|_of_execution}


(включая защищенные члены)

CLASS {Thread|_of_execution} , UNTESTED, NATIVE:


The {Thread} class purpose is to provide running code in a separate thread or process totally isolated from other (and from the main) threads. The only data which can be (partially) sharing is the thread object itself. Be sure that threading does not make your application faster in most cases. E.g. you can not use multi-threading to speed up sorting large arrays, or make a lot of calculations with a lot of data. But it is possible to await asynchronous operations.


IMPORT : {NATIVE_Thread} .

INT Handle|_of_thread , READ


BOOL Is_controller|_of_thread , READ


  

FUNCTION Is_main_thread ==> BOOL



FUNCTION Count_threads ==> INT



------------------------------------------------- 'controlling from parent'

BOOL running|_called , READ


   

METHOD Running|_now ==> BOOL



METHOD Run|_thread_return_controller ==> {Thread} , NEW



METHOD Ended|_thread ==> BOOL


BOOL Stopping|_called , READ


BOOL Terminating


  

METHOD Stop|_thread ( BOOL Terminate )



FUNCTION Wait|_until_all_threads_ended (
     
{Thread} A|rray_of_threads [*] ,
     
INT Max|imal_time_milliseconds_0_to_wait_infinite ) ==> BOOL , NATIVE



------------------------------------------------ 'pass objects to {Thread}'

 

METHOD Take|_objects_to_handle (
     
{Object} A|rray_of_objects_passing [*] ,
     
BOOL Together|_with_hard_linked_objects )



---------------------------------------------------------------- 'priority'

   

ENUMERATION {priority} :

        'BACKGROUND' ,

        'LOW|_PRIORITY' ,

        'NORMAL|_PRIORITY' ,

        'HIGH|_PRIORITY' ,

        'HIGHEST|_PRIORITY' .



METHOD Priority ==> {priority}



METHOD Set_priority ( {priority} Value|_to_set )



------------------------------------- 'override execute in your descendant'

 

METHOD execute|_this_thread , CALLBACK



-------------------------------------------------------- 'exchange objects'

  

METHOD receive|_objects_passed (
     
{Object} A|rray_of_objects_passed [] ,
     
BOOL Wait|_at_least_1_object ) , CALLBACK



METHOD yield|_objects_to_parent_thread (
     
{Object} A|rray_of_objects_yielding [*] ) , CALLBACK


END