void usb_init(int (*spawnD)()) { if (!initialized) { notificationIterators = (io_iterator_t*)malloc( vendorIdCount * sizeof(io_iterator_t)); adb_mutex_init(&start_lock, NULL); adb_cond_init(&start_cond, NULL); D("Before thread_create"); if(spawnD()) fatal_errno("cannot create RunLoopThread"); D("After thread_create"); // Wait for initialization to finish adb_mutex_lock(&start_lock); adb_cond_wait(&start_cond, &start_lock); adb_mutex_unlock(&start_lock); adb_mutex_destroy(&start_lock); adb_cond_destroy(&start_cond); initialized = 1; } }
void usb_init() { if (!initialized) { adb_thread_t tid; notificationIterators = (io_iterator_t*)malloc( vendorIdCount * sizeof(io_iterator_t)); adb_mutex_init(&start_lock, NULL); adb_cond_init(&start_cond, NULL); if(adb_thread_create(&tid, RunLoopThread, NULL)) fatal_errno("cannot create input thread"); // Wait for initialization to finish adb_mutex_lock(&start_lock); adb_cond_wait(&start_cond, &start_lock); adb_mutex_unlock(&start_lock); adb_mutex_destroy(&start_lock); adb_cond_destroy(&start_cond); initialized = 1; } }
void usb_init() { static bool initialized = false; if (!initialized) { atexit(usb_cleanup); adb_mutex_init(&start_lock, NULL); adb_cond_init(&start_cond, NULL); if (!adb_thread_create(RunLoopThread, nullptr)) { fatal_errno("cannot create input thread"); } // Wait for initialization to finish adb_mutex_lock(&start_lock); adb_cond_wait(&start_cond, &start_lock); adb_mutex_unlock(&start_lock); adb_mutex_destroy(&start_lock); adb_cond_destroy(&start_cond); initialized = true; } }
void usb_init() { if (!initialized) { adb_thread_t tid; adb_mutex_init(&start_lock, NULL); adb_cond_init(&start_cond, NULL); if(adb_thread_create(&tid, RunLoopThread, NULL)) fatal_errno("cannot create input thread"); // Wait for initialization to finish adb_mutex_lock(&start_lock); adb_cond_wait(&start_cond, &start_lock); adb_mutex_unlock(&start_lock); adb_mutex_destroy(&start_lock); adb_cond_destroy(&start_cond); initialized = 1; } }