static void gvl_yield(rb_vm_t *vm, rb_thread_t *th) { gvl_release(th->vm); native_thread_yield(); gvl_acquire(vm, th); }
static void gvl_atfork(rb_vm_t *vm) { if (GVL_DEBUG) fprintf(stderr, "gvl atfork\n"); gvl_init(vm); gvl_acquire(vm, GET_THREAD()); }
static int w32_wait_events(HANDLE *events, int count, DWORD timeout, rb_thread_t *th) { HANDLE *targets = events; HANDLE intr; DWORD ret; thread_debug(" w32_wait_events events:%p, count:%d, timeout:%ld, th:%p\n", events, count, timeout, th); if (th && (intr = th->native_thread_data.interrupt_event)) { gvl_acquire(th->vm, th); if (intr == th->native_thread_data.interrupt_event) { w32_reset_event(intr); if (RUBY_VM_INTERRUPTED(th)) { w32_set_event(intr); } targets = ALLOCA_N(HANDLE, count + 1); memcpy(targets, events, sizeof(HANDLE) * count); targets[count++] = intr; thread_debug(" * handle: %p (count: %d, intr)\n", intr, count); } gvl_release(th->vm); } thread_debug(" WaitForMultipleObjects start (count: %d)\n", count); ret = WaitForMultipleObjects(count, targets, FALSE, timeout); thread_debug(" WaitForMultipleObjects end (ret: %lu)\n", ret); if (ret == (DWORD)(WAIT_OBJECT_0 + count - 1) && th) { errno = EINTR; } if (ret == WAIT_FAILED && THREAD_DEBUG) { int i; DWORD dmy; for (i = 0; i < count; i++) { thread_debug(" * error handle %d - %s\n", i, GetHandleInformation(targets[i], &dmy) ? "OK" : "NG"); } } return ret; }
static void gvl_atfork(rb_vm_t *vm) { gvl_init(vm); gvl_acquire(vm, GET_THREAD()); }