ThriftClient::ThriftClient() { _contextQueue = gcnew ContextQueue(); _transportPool = gcnew Queue<FrameTransport^>(); _loop = uv_loop_new(); _notifier = new uv_async_t(); _notifier->data = _contextQueue->ToPointer(); uv_async_init(_loop, _notifier, NotifyCompleted); _stop = new uv_async_t(); uv_async_init(_loop, _stop, StopCompleted); }
static svc_baton* svc_create_baton(uv_loop_t* loop, const char* name, int main_ref, int cb_ref) { svc_baton* baton = LocalAlloc(LPTR, sizeof(svc_baton)); baton->lua_main_ref = main_ref; baton->block.lua_cb_ref = cb_ref; baton->name = _strdup(name); uv_async_init(loop, &baton->svc_async_handle, svcmain_cb); uv_async_init(loop, &baton->block.async_handle, svchandler_cb); baton->svc_async_handle.data = baton; baton->block.async_handle.data = baton; baton->svc_end_event = CreateEvent(NULL, TRUE, FALSE, NULL); baton->block.block_end_event = CreateEvent(NULL, TRUE, FALSE, NULL); baton->next = NULL; return baton; }
void eventpool_init(enum eventpool_threads_t t) { /* * Make sure we execute in the main thread */ const uv_thread_t pth_cur_id = uv_thread_self(); assert(uv_thread_equal(&pth_main_id, &pth_cur_id)); if(eventpoolinit == 1) { return; } eventpoolinit = 1; threads = t; if((async_req = MALLOC(sizeof(uv_async_t))) == NULL) { OUT_OF_MEMORY /*LCOV_EXCL_LINE*/ } uv_async_init(uv_default_loop(), async_req, eventpool_execute); if(lockinit == 0) { lockinit = 1; // pthread_mutexattr_init(&listeners_attr); // pthread_mutexattr_settype(&listeners_attr, PTHREAD_MUTEX_RECURSIVE); // pthread_mutex_init(&listeners_lock, &listeners_attr); uv_mutex_init(&listeners_lock); } }
// shutdown shuts down the Node's event loop and cleans up resources. void shutdown() { uv_async_init(m_uv_loop.get(), &m_async, [](uv_async_t* handle) { auto self = (Node*)(handle->data); auto timer = self->m_timer.get(); uv_timer_stop(timer); uv_close((uv_handle_t*)timer, [](uv_handle_t* handle) { auto self = (Node*)(handle->data); auto tcp = self->m_tcp.get(); auto loop = self->m_uv_loop.get(); self->m_peer_registry = nullptr; uv_close((uv_handle_t*)tcp, [](uv_handle_t* handle) { auto self = (Node*)(handle->data); auto loop = self->m_uv_loop.get(); uv_walk(loop, [](uv_handle_t* handle, void* arg) { if (uv_is_closing(handle) == 0) { uv_close(handle, [](uv_handle_t* h){}); } }, nullptr); }); }); }); m_async.data = this; uv_async_send(&m_async); }
static void tcp_bind(uv_loop_t *loop, struct server_context *server) { int rc; uv_tcp_init(loop, &server->tcp); rc = uv_tcp_open(&server->tcp, server->tcp_fd); if (rc) { logger_stderr("tcp open error: %s", uv_strerror(rc)); } uv_async_init(loop, &server->async_handle, consumer_close); rc = uv_tcp_bind(&server->tcp, server->local_addr, 0); if (rc || errno) { logger_stderr("bind error: %s", rc ? uv_strerror(rc) : strerror(errno)); exit(1); } rc = uv_listen((uv_stream_t*)&server->tcp, SOMAXCONN, server->accept_cb); if (rc) { logger_stderr("listen error: %s", rc ? uv_strerror(rc) : strerror(errno)); exit(1); } }
int nub_thread_create(nub_loop_t* loop, nub_thread_t* thread) { uv_async_t* async_handle; int er; async_handle = (uv_async_t*) malloc(sizeof(*async_handle)); CHECK_NE(NULL, async_handle); er = uv_async_init(&loop->uvloop, async_handle, nub__work_signal_cb); ASSERT(0 == er); async_handle->data = thread; thread->async_signal_ = async_handle; ASSERT(uv_loop_alive(&loop->uvloop)); er = uv_sem_init(&thread->thread_lock_sem_, 0); ASSERT(0 == er); er = uv_sem_init(&thread->sem_wait_, 1); ASSERT(0 == er); fuq_init(&thread->incoming_); thread->disposed = 0; thread->nubloop = loop; thread->disposed_cb_ = NULL; thread->work.thread = thread; thread->work.work_type = NUB_LOOP_QUEUE_NONE; ++loop->ref_; return uv_thread_create(&thread->uvthread, nub__thread_entry_cb, thread); }
int iotjs_tizen_bridge_native(const char* fn_name, unsigned fn_name_size, const char* message, unsigned message_size, user_callback_t cb) { iotjs_environment_t* env = iotjs_environment_get(); if (env->state != kRunningMain && env->state != kRunningLoop) { return IOTJS_ERROR_RESULT_FAILED; } iotjs_call_jfunc_t* handle = IOTJS_ALLOC(iotjs_call_jfunc_t); if (handle == NULL) { return IOTJS_ERROR_OUT_OF_MEMORY; } handle->async.data = (void*)handle; handle->fn_name = create_string_buffer(fn_name, fn_name_size); handle->message = create_string_buffer(message, message_size); handle->module = create_string_buffer(IOTJS_MAGIC_STRING_TIZEN, sizeof(IOTJS_MAGIC_STRING_TIZEN)); handle->cb = cb; uv_loop_t* loop = iotjs_environment_loop(env); uv_async_init(loop, &handle->async, bridge_native_async_handler); uv_async_send(&handle->async); return IOTJS_ERROR_NONE; }
static int Async_tp_init(Async *self, PyObject *args, PyObject *kwargs) { int r; Loop *loop; PyObject *callback, *tmp; UNUSED_ARG(kwargs); RAISE_IF_HANDLE_INITIALIZED(self, -1); if (!PyArg_ParseTuple(args, "O!O:__init__", &LoopType, &loop, &callback)) { return -1; } if (!PyCallable_Check(callback)) { PyErr_SetString(PyExc_TypeError, "a callable is required"); return -1; } r = uv_async_init(loop->uv_loop, (uv_async_t *)UV_HANDLE(self), on_async_callback); if (r != 0) { RAISE_UV_EXCEPTION(loop->uv_loop, PyExc_AsyncError); return -1; } tmp = self->callback; Py_INCREF(callback); self->callback = callback; Py_XDECREF(tmp); initialize_handle(HANDLE(self), loop); return 0; }
ClientWrap::ClientWrap( int compileGuarded ) : m_mutex("Node.js ClientWrap") { std::vector<std::string> pluginPaths; Plug::AppendUserPaths( pluginPaths ); Plug::AppendGlobalPaths( pluginPaths ); CG::CompileOptions compileOptions; if ( compileGuarded > -1 ) compileOptions.setGuarded( compileGuarded ); else compileOptions.setGuarded( false ); RC::Handle<IO::Manager> ioManager = IOManager::Create( &ClientWrap::ScheduleAsyncUserCallback, this ); RC::Handle<DG::Context> dgContext = DG::Context::Create( ioManager, pluginPaths, compileOptions, true ); #if defined(FABRIC_MODULE_OPENCL) OCL::registerTypes( dgContext->getRTManager() ); #endif Plug::Manager::Instance()->loadBuiltInPlugins( pluginPaths, dgContext->getCGManager(), DG::Context::GetCallbackStruct() ); m_client = Client::Create( dgContext, this ); m_mainThreadTLS = true; uv_async_init( uv_default_loop(), &m_uvAsync, &ClientWrap::AsyncCallback ); m_uvAsync.data = this; //// uv_timer_init adds a loop reference. (That is, it calls uv_ref.) This //// is not the behavior we want in Node. Timers should not increase the //// ref count of the loop except when active. //uv_unref( uv_default_loop() ); }
static int luv_queue_channel_new(lua_State* L) { const char* name = luv_queue_lua_arg_string(L, 1, NULL, queue_usage_new); int limit = luv_queue_lua_arg_integer(L, 2, 1, 0, queue_usage_new); luv_queue_t* queue = luv_queue_create(name, limit); if (lua_gettop(L) >= 3) { lua_pushvalue(L, 3); queue->async_cb = luaL_ref(L, LUA_REGISTRYINDEX); uv_async_init(luv_loop(L), &queue->async, luv_queue_async_callback); queue->async.data = queue; } else { queue->async_cb = LUA_REFNIL; queue->async.data = NULL; } queue->L = L; if (!luv_queues_add(queue)) { luv_queue_destroy(queue); lua_pushnil(L); lua_pushstring(L, "chan name duplicated"); return 2; } luv_queue_channel_push_queue(L, queue); return 1; }
void connection_consumer_start(void *arg) { int rc; struct server_ctx *ctx; uv_loop_t* loop; ctx = arg; loop = uv_loop_new(); listener_event_loops[ctx->index] = *loop; http_request_cache_configure_listener(loop, &listener_async_handles[ctx->index]); uv_barrier_wait(listeners_created_barrier); rc = uv_async_init(loop, &ctx->async_handle, connection_consumer_close); uv_unref((uv_handle_t*) &ctx->async_handle); /* Wait until the main thread is ready. */ uv_sem_wait(&ctx->semaphore); get_listen_handle(loop, (uv_stream_t*) &ctx->server_handle); uv_sem_post(&ctx->semaphore); rc = uv_listen((uv_stream_t*)&ctx->server_handle, 128, connection_consumer_new_connection); rc = uv_run(loop, UV_RUN_DEFAULT); uv_loop_delete(loop); }
lcb_luv_socket_t lcb_luv_socket_new(struct lcb_io_opt_st *iops) { /* Find the next 'file descriptor' */ lcb_socket_t idx; lcb_luv_socket_t newsock; idx = find_free_idx(IOPS_COOKIE(iops)); if (idx == -1) { iops->v.v0.error = ENFILE; return NULL; } newsock = calloc(1, sizeof(struct lcb_luv_socket_st)); newsock->idx = idx; newsock->parent = IOPS_COOKIE(iops); uv_async_init(newsock->parent->loop, &newsock->async, async_cb); newsock->async_state = 0; newsock->async.data = newsock; newsock->u_req.req.data = newsock; newsock->refcount = 1; uv_tcp_init(IOPS_COOKIE(iops)->loop, &newsock->tcp); IOPS_COOKIE(iops)->socktable[idx] = newsock; iops->v.v0.error = 0; log_socket_debug("%p: Created new socket %p(%d)", iops, newsock, idx); return newsock; }
static int luv_new_work(lua_State* L) { size_t len; const char* buff; luv_work_ctx_t* ctx; buff = luv_thread_dumped(L, 1, &len); luaL_checktype(L, 2, LUA_TFUNCTION); if(!lua_isnoneornil(L, 3)) luaL_checktype(L, 3, LUA_TFUNCTION); ctx = lua_newuserdata(L, sizeof(*ctx)); memset(ctx, 0, sizeof(*ctx)); ctx->len = len; ctx->code = malloc(ctx->len); memcpy(ctx->code, buff, len); lua_pushvalue(L, 2); ctx->after_work_cb = luaL_ref(L, LUA_REGISTRYINDEX); if (lua_gettop(L) == 4) { lua_pushvalue(L, 3); ctx->async_cb = luaL_ref(L, LUA_REGISTRYINDEX); uv_async_init(luv_loop(L), &ctx->async, async_cb); } else ctx->async_cb = LUA_REFNIL; ctx->L = L; luaL_getmetatable(L, "luv_work_ctx"); lua_setmetatable(L, -2); return 1; }
AsyncQueue(uv_loop_t *loop, std::function<void(T &)> fn) : callback(fn) { async.data = this; uv_async_init(loop, &async, [](UV_ASYNC_PARAMS(handle)) { auto q = reinterpret_cast<AsyncQueue *>(handle->data); q->process(); }); }
int main() { uv_thread_t tid; loop = create_loop(); async_handle = malloc(sizeof(uv_async_t)); uv_async_init(loop, async_handle, async_callback); uv_thread_create(&tid, thread_main, NULL); uv_async_send(async_handle); uv_thread_join(&tid); }
void V8SynchronizationContext::Initialize() { // This executes on V8 thread V8SynchronizationContext::uv_edge_async = new uv_edge_async_t; uv_async_init(uv_default_loop(), &V8SynchronizationContext::uv_edge_async->uv_async, continueOnV8Thread); V8SynchronizationContext::Unref(V8SynchronizationContext::uv_edge_async); V8SynchronizationContext::funcWaitHandle = gcnew AutoResetEvent(true); }
ThreadPool::ThreadPool() { loop_ = (uv_loop_t*)malloc(sizeof *loop_); UV_CHECK(uv_loop_init(loop_)); UV_CHECK(uv_async_init(loop_, &async_, thread_pool_async_cb)); async_.data = (void*)(this); thread_.reset(new thread([=] () { UV_CHECK(uv_run(loop_, UV_RUN_DEFAULT)); })); }
void extract_options(Local<Object> options, void* cptr, sass_context_wrapper* ctx_w, bool is_file, bool is_sync) { NanScope(); struct Sass_Context* ctx; NanAssignPersistent(ctx_w->result, options->Get(NanNew("result"))->ToObject()); if (is_file) { ctx_w->fctx = (struct Sass_File_Context*) cptr; ctx = sass_file_context_get_context(ctx_w->fctx); } else { ctx_w->dctx = (struct Sass_Data_Context*) cptr; ctx = sass_data_context_get_context(ctx_w->dctx); } struct Sass_Options* sass_options = sass_context_get_options(ctx); ctx_w->importer_callback = NULL; ctx_w->is_sync = is_sync; if (!is_sync) { ctx_w->request.data = ctx_w; // async (callback) style Local<Function> success_callback = Local<Function>::Cast(options->Get(NanNew("success"))); Local<Function> error_callback = Local<Function>::Cast(options->Get(NanNew("error"))); ctx_w->success_callback = new NanCallback(success_callback); ctx_w->error_callback = new NanCallback(error_callback); } Local<Function> importer_callback = Local<Function>::Cast(options->Get(NanNew("importer"))); if (importer_callback->IsFunction()) { ctx_w->importer_callback = new NanCallback(importer_callback); uv_async_init(uv_default_loop(), &ctx_w->async, (uv_async_cb)dispatched_async_uv_callback); sass_option_set_importer(sass_options, sass_make_importer(sass_importer, ctx_w)); } if(!is_file) { sass_option_set_input_path(sass_options, create_string(options->Get(NanNew("file")))); } sass_option_set_output_path(sass_options, create_string(options->Get(NanNew("outFile")))); sass_option_set_image_path(sass_options, create_string(options->Get(NanNew("imagePath")))); sass_option_set_output_style(sass_options, (Sass_Output_Style)options->Get(NanNew("style"))->Int32Value()); sass_option_set_is_indented_syntax_src(sass_options, options->Get(NanNew("indentedSyntax"))->BooleanValue()); sass_option_set_source_comments(sass_options, options->Get(NanNew("comments"))->BooleanValue()); sass_option_set_omit_source_map_url(sass_options, options->Get(NanNew("omitSourceMapUrl"))->BooleanValue()); sass_option_set_source_map_embed(sass_options, options->Get(NanNew("sourceMapEmbed"))->BooleanValue()); sass_option_set_source_map_contents(sass_options, options->Get(NanNew("sourceMapContents"))->BooleanValue()); sass_option_set_source_map_file(sass_options, create_string(options->Get(NanNew("sourceMap")))); sass_option_set_include_path(sass_options, create_string(options->Get(NanNew("paths")))); sass_option_set_precision(sass_options, options->Get(NanNew("precision"))->Int32Value()); }
void as_event_register_external_loop(as_event_loop* event_loop) { // This method is only called when user sets an external event loop. event_loop->wakeup = cf_malloc(sizeof(uv_async_t)); as_queue_init(&event_loop->queue, sizeof(as_uv_command), AS_EVENT_QUEUE_INITIAL_CAPACITY); // Assume uv_async_init is called on the same thread as the event loop. uv_async_init(event_loop->loop, event_loop->wakeup, as_uv_wakeup); }
Error TLSConnectionPrivate::Connect(const std::string &ipaddr, int port, TLSConnectionOptions *opts) { int err; loop_ = uv_loop_new(); struct sockaddr_in addr = uv_ip4_addr(ipaddr.c_str(), port); err = uv_tcp_init(loop_, &tcpsock_); if (err != UV_OK) { return UVUtils::ErrorFromLastUVError(loop_); } if (opts != nullptr) { uv_tcp_nodelay(&tcpsock_, opts->tcp_no_delay ? 1 : 0); } tcpconn_.data = static_cast<void *>(this); tcpsock_.data = static_cast<void *>(this); err = uv_tcp_connect(&tcpconn_, &tcpsock_, addr, TLSConnectionPrivate::OnConnect); if (err != UV_OK) { return UVUtils::ErrorFromLastUVError(loop_); } uv_mutex_init(&wqlock_); uv_async_init(loop_, &wqasync_, TLSConnectionPrivate::OnDrainWriteQueue); wqasync_.data = this; uv_async_init(loop_, &dcasync_, TLSConnectionPrivate::OnDisconnectRequest); dcasync_.data = this; state_ = TLS_CONNECTION_STATE_PRE_CONNECT; err = uv_thread_create(&thread_, TLSConnectionPrivate::TLSConnectionThread, this); if (err == -1) { return Error::ErrorFromDescription( std::string("TLSConnection"), 0L, std::string("unable to create connection thread") ); } return Error::NoError(); }
static void worker_thread(void* arg) { ls_worker_t* w = (ls_worker_t*)arg; w->worker_loop = uv_loop_new(); uv_async_init(w->worker_loop, &(w->worker_async), worker_async_callback); w->worker_started = 1; uv_run(w->worker_loop, UV_RUN_DEFAULT); LOG(" worker_thread[%p] terminate\n", w); }
static int uv__loop_init(uv_loop_t* loop, int default_loop) { unsigned int i; int err; uv__signal_global_once_init(); memset(loop, 0, sizeof(*loop)); RB_INIT(&loop->timer_handles); QUEUE_INIT(&loop->wq); QUEUE_INIT(&loop->active_reqs); QUEUE_INIT(&loop->idle_handles); QUEUE_INIT(&loop->async_handles); QUEUE_INIT(&loop->check_handles); QUEUE_INIT(&loop->prepare_handles); QUEUE_INIT(&loop->handle_queue); loop->nfds = 0; loop->watchers = NULL; loop->nwatchers = 0; QUEUE_INIT(&loop->pending_queue); QUEUE_INIT(&loop->watcher_queue); loop->closing_handles = NULL; loop->time = uv__hrtime() / 1000000; uv__async_init(&loop->async_watcher); loop->signal_pipefd[0] = -1; loop->signal_pipefd[1] = -1; loop->backend_fd = -1; loop->emfile_fd = -1; loop->timer_counter = 0; loop->stop_flag = 0; err = uv__platform_loop_init(loop, default_loop); if (err) return err; uv_signal_init(loop, &loop->child_watcher); uv__handle_unref(&loop->child_watcher); loop->child_watcher.flags |= UV__HANDLE_INTERNAL; for (i = 0; i < ARRAY_SIZE(loop->process_handles); i++) QUEUE_INIT(loop->process_handles + i); if (uv_mutex_init(&loop->wq_mutex)) abort(); if (uv_async_init(loop, &loop->wq_async, uv__work_done)) abort(); uv__handle_unref(&loop->wq_async); loop->wq_async.flags |= UV__HANDLE_INTERNAL; return 0; }
int uv_loop_init(uv_loop_t* loop) { int err; uv__signal_global_once_init(); memset(loop, 0, sizeof(*loop)); heap_init((struct heap*) &loop->timer_heap); QUEUE_INIT(&loop->wq); QUEUE_INIT(&loop->active_reqs); QUEUE_INIT(&loop->idle_handles); QUEUE_INIT(&loop->async_handles); QUEUE_INIT(&loop->check_handles); QUEUE_INIT(&loop->prepare_handles); QUEUE_INIT(&loop->handle_queue); loop->nfds = 0; loop->watchers = NULL; loop->nwatchers = 0; QUEUE_INIT(&loop->pending_queue); QUEUE_INIT(&loop->watcher_queue); loop->closing_handles = NULL; uv__update_time(loop); uv__async_init(&loop->async_watcher); loop->signal_pipefd[0] = -1; loop->signal_pipefd[1] = -1; loop->backend_fd = -1; loop->emfile_fd = -1; loop->timer_counter = 0; loop->stop_flag = 0; err = uv__platform_loop_init(loop); if (err) return err; uv_signal_init(loop, &loop->child_watcher); uv__handle_unref(&loop->child_watcher); loop->child_watcher.flags |= UV__HANDLE_INTERNAL; QUEUE_INIT(&loop->process_handles); if (uv_rwlock_init(&loop->cloexec_lock)) abort(); if (uv_mutex_init(&loop->wq_mutex)) abort(); if (uv_async_init(loop, &loop->wq_async, uv__work_done)) abort(); uv__handle_unref(&loop->wq_async); loop->wq_async.flags |= UV__HANDLE_INTERNAL; return 0; }
static void uv_finit(void) { //uv_unref((uv_handle_t*)&g_timer); uv_timer_stop(&g_timer); uv_stop(&g_loop); uv_async_init(&g_loop, &g_async, NULL); uv_async_send(&g_async); uv_thread_join(&g_loop_thread); if (g_sys) delete g_sys; //if (g_remote) delete g_remote; }
EventServer::EventServer() : thread_id_(std::this_thread::get_id()) { CHECK_EQ(0, uv_loop_init(&uv_loop_)); async_handle_ = new AsyncHandle; async_handle_->es = this; async_handle_->uv_handle.data = async_handle_; CHECK_EQ(0, uv_async_init(&uv_loop_, &async_handle_->uv_handle, &EventServer::uv_async_cb)); }
int uv_loop_init(uv_loop_t* loop) { /* Initialize libuv itself first */ uv__once_init(); /* Create an I/O completion port */ loop->iocp = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1); if (loop->iocp == NULL) return uv_translate_sys_error(GetLastError()); /* To prevent uninitialized memory access, loop->time must be initialized * to zero before calling uv_update_time for the first time. */ loop->time = 0; uv_update_time(loop); QUEUE_INIT(&loop->wq); QUEUE_INIT(&loop->handle_queue); QUEUE_INIT(&loop->active_reqs); loop->active_handles = 0; loop->pending_reqs_tail = NULL; loop->endgame_handles = NULL; RB_INIT(&loop->timers); loop->check_handles = NULL; loop->prepare_handles = NULL; loop->idle_handles = NULL; loop->next_prepare_handle = NULL; loop->next_check_handle = NULL; loop->next_idle_handle = NULL; memset(&loop->poll_peer_sockets, 0, sizeof loop->poll_peer_sockets); loop->active_tcp_streams = 0; loop->active_udp_streams = 0; loop->timer_counter = 0; loop->stop_flag = 0; if (uv_mutex_init(&loop->wq_mutex)) abort(); if (uv_async_init(loop, &loop->wq_async, uv__work_done)) abort(); uv__handle_unref(&loop->wq_async); loop->wq_async.flags |= UV__HANDLE_INTERNAL; return 0; }
extern "C" void* rust_uv_bind_op_cb(uv_loop_t* loop, extern_async_op_cb cb) { uv_async_t* async = (uv_async_t*)current_kernel_malloc( sizeof(uv_async_t), "uv_async_t"); uv_async_init(loop, async, foreign_extern_async_op_cb); async->data = (void*)cb; // decrement the ref count, so that our async bind // doesn't count towards keeping the loop alive //uv_unref(loop); return async; }
int uv__loop_init(uv_loop_t* loop, int default_loop) { unsigned int i; int flags; uv__signal_global_once_init(); #if HAVE_KQUEUE flags = EVBACKEND_KQUEUE; #else flags = EVFLAG_AUTO; #endif memset(loop, 0, sizeof(*loop)); RB_INIT(&loop->timer_handles); ngx_queue_init(&loop->wq); ngx_queue_init(&loop->active_reqs); ngx_queue_init(&loop->idle_handles); ngx_queue_init(&loop->async_handles); ngx_queue_init(&loop->check_handles); ngx_queue_init(&loop->prepare_handles); ngx_queue_init(&loop->handle_queue); loop->closing_handles = NULL; loop->time = uv_hrtime() / 1000000; loop->async_pipefd[0] = -1; loop->async_pipefd[1] = -1; loop->async_sweep_needed = 0; loop->signal_pipefd[0] = -1; loop->signal_pipefd[1] = -1; loop->emfile_fd = -1; loop->ev = (default_loop ? ev_default_loop : ev_loop_new)(flags); ev_set_userdata(loop->ev, loop); uv_signal_init(loop, &loop->child_watcher); uv__handle_unref(&loop->child_watcher); loop->child_watcher.flags |= UV__HANDLE_INTERNAL; for (i = 0; i < ARRAY_SIZE(loop->process_handles); i++) ngx_queue_init(loop->process_handles + i); if (uv_mutex_init(&loop->wq_mutex)) abort(); if (uv_async_init(loop, &loop->wq_async, uv__work_done)) abort(); uv__handle_unref(&loop->wq_async); loop->wq_async.flags |= UV__HANDLE_INTERNAL; if (uv__platform_loop_init(loop, default_loop)) return -1; return 0; }
extern "C" void* rust_uv_hilvl_async_init(uv_loop_t* loop, extern_simple_cb cb, uint8_t* buf) { uv_async_t* async = (uv_async_t*)current_kernel_malloc( sizeof(uv_async_t), "uv_async_t"); uv_async_init(loop, async, foreign_async_cb); handle_data* data = new_handle_data_from(buf, cb); async->data = data; return async; }
/** libuv constructors */ DLLEXPORT uv_async_t *jl_make_async(uv_loop_t *loop,jl_value_t *julia_struct) { if (!loop) return 0; uv_async_t *async = malloc(sizeof(uv_async_t)); if (uv_async_init(loop,async,(uv_async_cb)&jl_asynccb)) { free(async); return 0; } async->data=julia_struct; return async; }