Fct_Dispatch_TAG
Fct_Dispatch_GLI
Fct_Dispatch_Other
Muti-thread dispatch function. For each frame in the"frame" list, this function will start the function "fct" in a separate thread. It will limit the number of concurrent threads to "COMPUTER_THREAD_NB". The function "fct" will receive as argument a pointer to the "Struct_Dispatch_2" structure.
If the variable "increment" is set, Fct_Dispatch_... will use it to prevent the concurrent threads from working on adjacent frames. For example, if "increment"=3, Dispatch will start threads with frames 0, 3, 6, 9, 12... instead of 0, 1, 2, 3, 4... This is used if computation of the frame's gradient necessitate values from the target frames and its immediate neighbours. By spreading the computation with "increment=3" we insure that the threads are not blocking one another by working on the same frames.
The function will also replace the cursor by an hourglass while the threads are processing.
Once all threads are finished the function will update the appropriate structures ("UPDATE_DISPLAY_TAG" for Fct_Dispatch_TAG or "UPDATE_DISPLAY_GLI" for Fct_Dispatch_GLI) and generate a redraw ("REDRAW_DB_OPENGL" for Fct_Dispatch_TAG and Fct_Dispatch_GLI, "redraw_flag" from the Struct_Dispatch_1 structure for Fct_Dispatch_Other.).
The Fct_Dispatch_TAG will also attempt to keep all TAG pixel modifications in an Undo. The label associated with the undo will be derived from the variables: "name" and "label" of the Struct_Dispatch_1 structure.
When the last user thread has finished, the function will place a "UPDATE_THREAD" signal in the update queue, and it will call the "fct_end" callback if it is present with a pointer to the "local_data" variable.
Syntax
unsigned __stdcall Fct_Dispatch_TAG(
void *pvoid
) ;
unsigned __stdcall Fct_Dispatch_GLI(
void *pvoid
) ;
unsigned __stdcall Fct_Dispatch_Other(
void *pvoid
) ;
Parameters
pvoid
Pointer to a Struct_Dispatch_1 structure.
typedef struct Struct_Dispatch_1 {
char * name ; // name for undo
char * label ; // label for undo
UInt64 redraw_flag ; // redraw flag for Dispatch_Other fct.
int nb_frame ; // number of frames to process
SliceO_Frame ** frame ; // list of the frames to process
SliceO_Window * window ; // pointer to current window
int increment ; // spread of the dispatch to minimize neighbour interferences
unsigned int stack_size ; // stack size if a special size is required (def=0)
void * progress ; // pointer to "Progress" window (def=0)
void * fct_thread ; // pointer to thread function ( unsigned int (*) (void *) )
void * fct_end ; // pointer to optional "end" callback function ( void (*) (void *) )
void * local_data ; // pointer to local data structure
} Struct_Dispatch_1 ;
Return value
This function returns "1".
Remarks
The function "fct". from the Struct_Dispatch_1 structure must call "Fct_Dispatch_End()" when it terminate. Failure to do so will result in a deadlock.
The function "fct" from the struct_Dispatch_1 structure is called with a "_beginthreadex" call.
The argument "stack_size" is taken from the Struct_Dispatch_1 structure.
The function is provided with a pointer to a Struct_Dispatch_2 structure containing a pointer to the target frame.
typedef struct Struct_Dispatch_2 {
SliceO_Frame * frame ; // pointer to the frame to process
SliceO_Window * window ; // pointer to current window
void * progress ; // pointer to "Progress" window (def=0)
void * local_data ; // pointer to local data structure
} Struct_Dispatch_2 ;
Requirements
Header:
sliceO_include.hpp
Library:
sliceO_Structures.lib
Example
See also