int gp_thread_start(gp_thread_creation_callback_t function, void *data, gp_thread_id *thread) { #ifdef FALLBACK_TO_OLD_THREADING_FUNCTIONS *thread = (gp_thread_id)1; return gp_create_thread(function, data); #else /* Create the magic closure that thread_wrapper gets passed */ HANDLE hThread; unsigned threadID; gp_thread_creation_closure *closure = (gp_thread_creation_closure *)malloc(sizeof(*closure)); if (!closure) return gs_error_VMerror; closure->function = function; closure->data = data; hThread = (HANDLE)_beginthreadex(NULL, 0, &gp_thread_start_wrapper, closure, 0, &threadID); if (hThread == (HANDLE)0) { free(closure); *thread = NULL; return_error(gs_error_unknownerror); } *thread = (gp_thread_id)hThread; return 0; #endif }
int clist_enable_multi_thread_render(gx_device *dev) { int code = -1; /* We need to test gp_create_thread since we may be on a platform */ /* built without working threads, i.e., using gp_nsync.c dummy */ /* routines. The nosync gp_create_thread returns a -ve error code */ if ((code = gp_create_thread(test_threads, NULL)) < 0 ) { return code; /* Threads don't work */ } set_dev_proc(dev, get_bits_rectangle, clist_get_bits_rect_mt); return 1; }
static int clist_start_render_thread(gx_device *dev, int thread_index, int band) { gx_device_clist *cldev = (gx_device_clist *)dev; gx_device_clist_reader *crdev = &cldev->reader; int code; crdev->render_threads[thread_index].band = band; crdev->render_threads[thread_index].status = RENDER_THREAD_BUSY; /* Finally, fire it up */ code = gp_create_thread(clist_render_thread, &(crdev->render_threads[thread_index])); return code; }