static int luv_has_ref(lua_State* L) { uv_handle_t* handle = luv_check_handle(L, 1); int ret = uv_has_ref(handle); if (ret < 0) return luv_error(L, ret); lua_pushboolean(L, ret); return 1; }
static PyObject * Handle_ref_get(Handle *self, void *closure) { UNUSED_ARG(closure); RAISE_IF_HANDLE_NOT_INITIALIZED(self, NULL); return PyBool_FromLong((long)uv_has_ref(self->uv_handle)); }
CAMLprim value camluv_has_ref(value handle) { CAMLparam1(handle); CAMLlocal1(has_ref); camluv_handle_t *camluv_handle = camluv_handle_struct_val(handle); if (camluv_handle_initialized(camluv_handle)) { // TODO: this handle is not initialized. has_ref = Val_int(0); CAMLreturn(has_ref); } if (uv_is_closing(camluv_handle->uv_handle)) { // TODO: this handle is closing. has_ref = Val_int(0); CAMLreturn(has_ref); } has_ref = Val_int(uv_has_ref(camluv_handle->uv_handle)); CAMLreturn(has_ref); }
void nub_loop_dispose(nub_loop_t* loop) { ASSERT(0 == uv_loop_alive(&loop->uvloop)); ASSERT(1 == fuq_empty(&loop->blocking_queue_)); ASSERT(0 == loop->ref_); ASSERT(NULL != loop->work_ping_); ASSERT(0 == uv_has_ref((uv_handle_t*) loop->work_ping_)); ASSERT(1 == fuq_empty(&loop->thread_dispose_queue_)); uv_close((uv_handle_t*) loop->work_ping_, nub__free_handle_cb); uv_close((uv_handle_t*) &loop->queue_processor_, NULL); ASSERT(0 == uv_is_active((uv_handle_t*) loop->work_ping_)); fuq_dispose(&loop->thread_dispose_queue_); uv_mutex_destroy(&loop->thread_dispose_lock_); uv_sem_destroy(&loop->loop_lock_sem_); fuq_dispose(&loop->blocking_queue_); uv_mutex_destroy(&loop->queue_processor_lock_); fuq_dispose(&loop->work_queue_); uv_mutex_destroy(&loop->work_lock_); CHECK_EQ(0, uv_run(&loop->uvloop, UV_RUN_NOWAIT)); CHECK_NE(UV_EBUSY, uv_loop_close(&loop->uvloop)); }
bool has_ref() { return uv_has_ref(as_base_handle())!=0; }