static void * thread_func(void * arg) { cliprdrPlugin * plugin; struct wait_obj * listobj[2]; int numobj; plugin = (cliprdrPlugin *) arg; plugin->thread_status = 1; LLOGLN(10, ("cliprdr_main thread_func: in")); while (1) { listobj[0] = plugin->term_event; listobj[1] = plugin->data_in_event; numobj = 2; wait_obj_select(listobj, numobj, NULL, 0, 500); if (wait_obj_is_set(plugin->term_event)) { break; } if (wait_obj_is_set(plugin->data_in_event)) { wait_obj_clear(plugin->data_in_event); /* process data in */ thread_process_data_in(plugin); } } LLOGLN(10, ("cliprdr_main thread_func: out")); plugin->thread_status = -1; return 0; }
//------------------------------------------------------------------------------ static void * received_data_processing_thread_func(void * arg) { railCorePlugin * plugin; struct wait_obj * listobj[2]; int numobj; plugin = (railCorePlugin *) arg; plugin->thread_status = 1; LLOGLN(10, ("rail_core_plugin:received_data_processing_thread_func: in")); while (1) { listobj[0] = plugin->term_event; listobj[1] = plugin->data_in_event; numobj = 2; wait_obj_select(listobj, numobj, NULL, 0, 500); if (wait_obj_is_set(plugin->term_event)) { break; } if (wait_obj_is_set(plugin->data_in_event)) { wait_obj_clear(plugin->data_in_event); /* process data in */ process_received_data(plugin); } } LLOGLN(10, ("rail_core_plugin:received_data_processing_thread_func: out")); plugin->thread_status = -1; return 0; }
void test_wait_obj(void) { struct wait_obj* wo; int set; wo = wait_obj_new(); set = wait_obj_is_set(wo); CU_ASSERT(set == 0); wait_obj_set(wo); set = wait_obj_is_set(wo); CU_ASSERT(set == 1); wait_obj_clear(wo); set = wait_obj_is_set(wo); CU_ASSERT(set == 0); wait_obj_select(&wo, 1, 1000); wait_obj_free(wo); }
static void * thread_func(void * arg) { rdpsndPlugin * plugin; struct wait_obj * listobj[2]; int numobj; int timeout; plugin = (rdpsndPlugin *) arg; plugin->thread_status = 1; LLOGLN(10, ("thread_func: in")); while (1) { listobj[0] = plugin->term_event; listobj[1] = plugin->data_in_event; numobj = 2; timeout = plugin->out_list_head == 0 ? -1 : 500; wait_obj_select(listobj, numobj, NULL, 0, timeout); if (wait_obj_is_set(plugin->term_event)) { break; } if (wait_obj_is_set(plugin->data_in_event)) { wait_obj_clear(plugin->data_in_event); /* process data in */ thread_process_data_in(plugin); } if (plugin->out_list_head != 0) { thread_process_data_out(plugin); } } LLOGLN(10, ("thread_func: out")); plugin->thread_status = -1; return 0; }