Max 5 API Reference
00001 #ifndef __PARALLEL_H__ 00002 #define __PARALLEL_H__ 00003 00004 #if C74_PRAGMA_STRUCT_PACKPUSH 00005 #pragma pack(push, 2) 00006 #elif C74_PRAGMA_STRUCT_PACK 00007 #pragma pack(2) 00008 #endif 00009 00010 #ifdef __cplusplus 00011 extern "C" { 00012 #endif // __cplusplus 00013 00014 00015 #define PARALLEL_PRIORITY_DEFAULT 0x00 00016 #define PARALLEL_PRIORITY_LOW 0x00 00017 #define PARALLEL_PRIORITY_MEDIUM 0x04 00018 #define PARALLEL_PRIORITY_HIGH 0x08 00019 00020 #define PARALLEL_MAX_WORKERS 8 00021 00022 #define PARALLEL_STATE_IDLE 0 00023 #define PARALLEL_STATE_RUN 1 00024 #define PARALLEL_STATE_DONE 2 00025 00026 typedef struct _parallel_task 00027 { 00028 t_object ob; 00029 void *obex; 00030 void *data; // global task data 00031 method workerproc; // worker callback function 00032 long workercount; // number of workers to use 00033 t_linklist *workers; // may wish to make a static array of some maximum size(32?) 00034 char priority; // thread priority 00035 char benchmark; // benchmark 00036 long iteration; // for benchmarking 00037 double begintime; // for benchmarking 00038 double endtime; // for benchmarking 00039 long cancel; // for cancel request 00040 // some maintenance of threads/semaphores to use for execute? 00041 } t_parallel_task; 00042 00043 00044 typedef struct _parallel_worker 00045 { 00046 t_object ob; 00047 void *obex; 00048 void *data; // worker specific data? 00049 method workerproc; // worker callback function, worker object passed in 00050 t_parallel_task *task; // pointer to task parent (can be used to access global task data) 00051 long id; // worker id 00052 double begintime; // for benchmarking (uses task info) 00053 double endtime; // for benchmarking (uses task info) 00054 // some maintenance of threads/semaphores to use for execute? 00055 00056 } t_parallel_worker; 00057 00058 00059 void parallel_init(void); 00060 long parallel_processorcount(void); 00061 t_parallel_task *parallel_task_new(void *data, method workerproc, long workercount); 00062 t_max_err parallel_task_execute(t_parallel_task *x); 00063 t_max_err parallel_task_cancel(t_parallel_task *x); 00064 void parallel_task_free(t_parallel_task *x); 00065 void parallel_task_benchprint(t_parallel_task *x); 00066 void parallel_task_data(t_parallel_task *x, void * data); 00067 void parallel_task_workerproc(t_parallel_task *x, method workerproc); 00068 00069 t_parallel_worker *parallel_worker_new(void *data, method workerproc, t_parallel_task *task); 00070 t_max_err parallel_worker_execute(t_parallel_worker *x); 00071 void parallel_worker_free(t_parallel_worker *x); 00072 00073 #ifdef __cplusplus 00074 } 00075 #endif // __cplusplus 00076 00077 #if C74_PRAGMA_STRUCT_PACKPUSH 00078 #pragma pack(pop) 00079 #elif C74_PRAGMA_STRUCT_PACK 00080 #pragma pack() 00081 #endif 00082 00083 #endif // __PARALLEL_H__
Copyright © 2008, Cycling '74