您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ uv_async_send函数代码示例

51自学网 2021-06-03 09:27:28
  C++
这篇教程C++ uv_async_send函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中uv_async_send函数的典型用法代码示例。如果您正苦于以下问题:C++ uv_async_send函数的具体用法?C++ uv_async_send怎么用?C++ uv_async_send使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了uv_async_send函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: unload_module

static int unload_module(void) {	unsigned int i = 0;	LNOTICE("unloaded module %s", module_name);	for (i = 0; i < profile_size; i++) {		close_socket(i);		free_profile(i);	}		                 #if UV_VERSION_MAJOR == 0	uv_async_send(&async_handle);	uv_loop_delete(loop);#else	if (uv_loop_alive(loop)) {        	uv_async_send(&async_handle);	}   	uv_stop(loop);	uv_loop_close(loop);	free(loop);#endif	/* Close socket */	return 0;}
开发者ID:SipSeb,项目名称:captagent,代码行数:28,


示例2: uv_async_send

void NodeMap::startRender(NodeMap::RenderOptions options) {    view.resize(options.width, options.height);    map->update(mbgl::Update::Dimensions);    map->setClasses(options.classes);    map->setLatLngZoom(mbgl::LatLng(options.latitude, options.longitude), options.zoom);    map->setBearing(options.bearing);    map->setPitch(options.pitch);    map->setDebug(options.debugOptions);    map->renderStill([this](const std::exception_ptr eptr, mbgl::PremultipliedImage&& result) {        if (eptr) {            error = std::move(eptr);            uv_async_send(async);        } else {            assert(!image.data);            image = std::move(result);            uv_async_send(async);        }    });    // Retain this object, otherwise it might get destructed before we are finished rendering the    // still image.    Ref();    // Similarly, we're now waiting for the async to be called, so we need to make sure that it    // keeps the loop alive.    uv_ref(reinterpret_cast<uv_handle_t *>(async));}
开发者ID:AJcravea,项目名称:mapbox-gl-native,代码行数:28,


示例3: addEventData

  void addEventData(myo::Myo* myo, uint64_t timestamp, std::string type, EventData *eventData)  {    std::map<myo::Myo*, std::string>::iterator iter = this->myo_ids.find(myo);    if (iter == this->myo_ids.end()) {      this->myo_ids[myo] = this->GUID();      this->addEventData(myo, timestamp, "connect", new EventData());    }    EventHandle* eventHandle = this->getEventHandle(type);    if (eventHandle == 0) {      printf("no eventhandle for event %s/n", type);      return;    }    std::string myo_id = this->myo_ids[myo];    eventData->myo_id = myo_id;    eventData->timestamp = timestamp;    // uv_rwlock_wrlock(&eventHandle->lock);    eventHandle->data.push(eventData);    // uv_rwlock_wrunlock(&eventHandle->lock);    uv_async_send(&eventHandle->async_handle);  }
开发者ID:DigitasLBi-SE-TechnologyLab,项目名称:myo-node,代码行数:26,


示例4: shutdown

	// 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);	}
开发者ID:Preetam,项目名称:libab,代码行数:31,


示例5: thread3_entry

/* Thread 3 calls uv_async_send on async_handle_2 8 times * after waiting half a second first. */void thread3_entry(void *arg) {  int i;  for (i = 0; i < 8; i++) {    uv_async_send(&async2_handle);  }}
开发者ID:benw,项目名称:node,代码行数:10,


示例6: after_work

 void after_work(uv_work_t* work, int status) {     ThreadPool* l = (ThreadPool*)((ThreadPool::work_data*)work->data)->tp_;     delete (ThreadPool::work_data*)work->data;     delete work;     --(l->count_);     uv_async_send(&l->async_);/*start thread_pool_async_cb*/ }
开发者ID:zhxfl,项目名称:purine2,代码行数:7,


示例7: nub_loop_lock

/* Should be run from spawned thread. */int nub_loop_lock(nub_thread_t* thread) {  fuq_queue_t* queue;  uv_mutex_t* mutex;  int er;  int is_empty;  ASSERT(NULL != thread);  queue = &thread->nubloop->work_queue_;  mutex = &thread->nubloop->work_lock_;  if (NUB_LOOP_QUEUE_DISPOSE != thread->work.work_type)    thread->work.work_type = NUB_LOOP_QUEUE_LOCK;  uv_mutex_lock(mutex);  is_empty = fuq_empty(queue);  fuq_enqueue(queue, &thread->work);  uv_mutex_unlock(mutex);  if (is_empty)    /* Send signal to event loop thread that work needs to be done. */    er = uv_async_send(thread->async_signal_);  else    er = 0;  /* Pause thread until uv_async_cb has run. */  uv_sem_wait(&thread->thread_lock_sem_);  return er;}
开发者ID:nubjs,项目名称:libnub,代码行数:31,


示例8: thread_cb

void thread_cb(void* arg) {  thread_comm_t* comm = (thread_comm_t*) arg;  printf("pre async send/n");  uv_async_send(&comm->async);  printf("post async send/n");}
开发者ID:rwaldron,项目名称:libuv-examples,代码行数:7,


示例9: uv_async_send

 Loop::~Loop() {     stop_ = true;     uv_async_send(&async_);     thread_->join();     UV_CHECK(uv_loop_close(loop_));     free(loop_); }
开发者ID:zhxfl,项目名称:purine2,代码行数:7,


示例10: send

 void send(T &&data) {     {         std::lock_guard<std::mutex> lock(mutex);         queue.push(std::make_unique<T>(std::move(data)));     }     uv_async_send(&async); }
开发者ID:AJcravea,项目名称:mapbox-gl-native,代码行数:7,


示例11: assert

void HTTPRequestBaton::start(const util::ptr<HTTPRequestBaton> &baton) {    assert(uv_thread_self() == baton->thread_id);    std::string clean_url = util::percentDecode(baton->path);    if (clean_url.find("local://") == 0) {        clean_url = base_directory + clean_url.substr(8);    }    baton->response = std::make_unique<Response>();    FILE *file = fopen(clean_url.c_str(),"rb");    if (file != NULL) {        fseek(file, 0, SEEK_END);        const size_t size = ftell(file);        fseek(file, 0, SEEK_SET);        baton->response->data.resize(size);        const size_t read = fread(&baton->response->data[0], 1, size, file);        fclose(file);        if (read == size) {            baton->response->code = 200;            baton->type = HTTPResponseType::Successful;        } else {            baton->response->code = 500;            baton->type = HTTPResponseType::PermanentError;            baton->response->message = "Read bytes differed from file size";        }    } else {        baton->type = HTTPResponseType::PermanentError;        baton->response->code = 404;    }    uv_async_send(baton->async);}
开发者ID:zhaochunliang,项目名称:mapbox-gl-native,代码行数:33,


示例12: readkbd

/* process individual kbd characters */void readkbd(uv_stream_t* stream, ssize_t nread, const uv_buf_t *buf) {    char* ch;    int i;        for (ch=buf->base, i=0; i<nread; i++) {        if(nread < 0) {            print("keyboard close (n=%d, %s)/n", nread, strerror(errno));        }                switch(*ch) {        case '/r':            *ch = '/n';            break;        case DELETE:            *ch = '/b';            break;        }                if(kbd.raw == 0){            switch(*ch){            case 0x15:                write(1, "^U/n", 3);                break;            default:                write(1, ch, 1);                break;            }        }        qproduce(kbdq, ch, 1);        uv_async_send(&ev_conschar);    }    if (buf->base) {free(buf->base);}}
开发者ID:AndreasBriese,项目名称:node9,代码行数:34,


示例13: as_event_send_close_loop

boolas_event_send_close_loop(as_event_loop* event_loop){	// Send stop command through queue so it can be executed in event loop thread.	pthread_mutex_lock(&event_loop->lock);	as_uv_command qcmd = {.type = AS_UV_EXIT_LOOP, .ptr = 0};	bool queued = as_queue_push(&event_loop->queue, &qcmd);	pthread_mutex_unlock(&event_loop->lock);		if (queued) {		uv_async_send(event_loop->wakeup);	}	return queued;}voidas_event_close_loop(as_event_loop* event_loop){	uv_close((uv_handle_t*)event_loop->wakeup, as_uv_wakeup_closed);		// Only stop event loop if client created event loop.	if (as_event_threads_created) {		uv_stop(event_loop->loop);	}		// Cleanup event loop resources.	as_queue_destroy(&event_loop->queue);	as_queue_destroy(&event_loop->pipe_cb_queue);	pthread_mutex_unlock(&event_loop->lock);	pthread_mutex_destroy(&event_loop->lock);}
开发者ID:BeeswaxIO,项目名称:aerospike-client-c,代码行数:31,


示例14: luv_queue_channel_send

static int luv_queue_channel_send(lua_State* L){	int type, ret;	luv_msg_t* msg;	luv_queue_t* queue = luv_queue_check_queue_t(L);	if (lua_gettop(L) < 2) {		luv_queue_lua_usage(L, queue_usage_send);	}	msg = (luv_msg_t*)malloc(sizeof(luv_msg_t));	ret = luv_thread_arg_set(L, &msg->arg, 2, lua_gettop(L), 1);	// printf("chan_send: %d/r/n", ret);	ret = luv_queue_send(queue, msg, 0);	if (!ret) {		luv_queue_message_release(msg);	} else {		if (queue->async_cb != LUA_REFNIL) {			uv_async_send(&(queue->async));		}	}	lua_pushboolean(L, ret);	return 1;}
开发者ID:czanyou,项目名称:node.lua,代码行数:26,


示例15: ONSConsumerACKInner

Action ONSListenerV8::consume(Message& message, ConsumeContext& context){    ONSConsumerACKInner* ack_inner = new ONSConsumerACKInner();    MessageHandlerParam* param = new MessageHandlerParam();    param->message = &message;    if(consumer_env_v == "true")    {        printf(">>> ACK Inner Created: 0x%lX/n", (unsigned long)ack_inner);        printf(">>> Message Handler Param Created: 0x%lX/n", (unsigned long)param);    }    param->ons = parent;    param->ack_inner = ack_inner;    async->data = (void*)param;    uv_async_send(async);    Action result = ack_inner->WaitResult();    delete ack_inner;    delete param;    if(consumer_env_v == "true")    {        printf(">>> ACK Inner Deleted: 0x%lX/n", (unsigned long)ack_inner);        printf(">>> Message Handler Param Deleted: 0x%lX/n", (unsigned long)param);    }    return result;}
开发者ID:pmq20,项目名称:aliyun-ons,代码行数:30,


示例16: pc_client_destroy

void pc_client_destroy(pc_client_t *client) {  if(PC_ST_INITED == client->state) {    pc__client_clear(client);    goto finally;  }  if(PC_ST_CLOSED == client->state) {    pc__client_clear(client);    goto finally;  }  // 1. asyn worker thread  // 2. wait work thread exit  // 3. free client  uv_async_send(client->close_async);  pc_client_join(client);  if(PC_ST_CLOSED != client->state) {    pc_client_stop(client);    // wait uv_loop_t stop    sleep(1);    pc__client_clear(client);  }finally:  if(client->uv_loop) {    uv_loop_delete(client->uv_loop);    client->uv_loop = NULL;  }  free(client);}
开发者ID:NewYuil,项目名称:libpomelo,代码行数:32,


示例17: switch

unsigned VlcVideoOutput::video_format_cb( char* chroma,                                          unsigned* width, unsigned* height,                                          unsigned* pitches, unsigned* lines ){    std::unique_ptr<VideoEvent> frameSetupEvent;    switch( _pixelFormat ) {        case PixelFormat::RV32: {            std::shared_ptr<RV32VideoFrame> videoFrame( new RV32VideoFrame() );            frameSetupEvent.reset( new RV32FrameSetupEvent( videoFrame ) );            _videoFrame = videoFrame;            break;        }        case PixelFormat::I420:        default: {            std::shared_ptr<I420VideoFrame> videoFrame( new I420VideoFrame() );            frameSetupEvent.reset( new I420FrameSetupEvent( videoFrame ) );            _videoFrame = videoFrame;            break;        }    }    const unsigned planeCount = _videoFrame->video_format_cb( chroma,                                                              width, height,                                                              pitches, lines );    _guard.lock();    _videoEvents.push_back( std::move( frameSetupEvent ) );    _guard.unlock();    uv_async_send( &_async );    _videoFrame->waitBuffer();    return planeCount;}
开发者ID:DavidYangfei,项目名称:WebChimera.js,代码行数:34,


示例18: loop_schedule

// Schedule an event from another threadvoid loop_schedule(Loop *loop, Event event){  uv_mutex_lock(&loop->mutex);  multiqueue_put_event(loop->thread_events, event);  uv_async_send(&loop->async);  uv_mutex_unlock(&loop->mutex);}
开发者ID:fatbird,项目名称:neovim,代码行数:8,


示例19: signal_cb

static voidsignal_cb(uv_signal_t *handle, int signum) {    if (signum == SIGINT || signum == SIGQUIT) {        char *name = signum == SIGINT ? "SIGINT" : "SIGQUIT";        logger_log(LOG_INFO, "Received %s, scheduling shutdown...", name);        close_signal();        if (concurrency > 1) {            struct server_context *servers = handle->data;            for (int i = 0; i < concurrency; i++) {                struct server_context *server = &servers[i];                uv_async_send(&server->async_handle);            }        } else {            struct server_context *ctx = handle->data;            uv_close((uv_handle_t *)&ctx->tcp, NULL);            udprelay_close(ctx);        }    }    if (signum == SIGTERM) {        logger_log(LOG_INFO, "Received SIGTERM, scheduling shutdown...");        if (daemon_mode) {            delete_pidfile(pidfile);        }        exit(0);    }}
开发者ID:WisdomKwan,项目名称:xsocks,代码行数:30,


示例20: embed_thread_runner

static void embed_thread_runner(void* arg) {  int r;  int fd;  int timeout;  while (!embed_closed) {    fd = uv_backend_fd(uv_default_loop());    timeout = uv_backend_timeout(uv_default_loop());    do {#if defined(HAVE_KQUEUE)      struct timespec ts;      ts.tv_sec = timeout / 1000;      ts.tv_nsec = (timeout % 1000) * 1000000;      r = kevent(fd, NULL, 0, NULL, 0, &ts);#elif defined(HAVE_EPOLL)      {        struct epoll_event ev;        r = epoll_wait(fd, &ev, 1, timeout);      }#endif    } while (r == -1 && errno == EINTR);    uv_async_send(&embed_async);    uv_sem_wait(&embed_sem);  }}
开发者ID:AlexanderPankiv,项目名称:node,代码行数:26,


示例21: DeviceRemoved

//================================================================================================////  DeviceRemoved////  This routine will get called whenever any kIOGeneralInterest notification happens.  We are//  interested in the kIOMessageServiceIsTerminated message so that's what we look for.  Other//  messages are defined in IOMessage.h.////================================================================================================static void DeviceRemoved(void *refCon, io_service_t service, natural_t messageType, void *messageArgument) {	kern_return_t kr;	stDeviceListItem* deviceListItem = (stDeviceListItem *) refCon;	DeviceItem_t* deviceItem = deviceListItem->deviceItem;	if(messageType == kIOMessageServiceIsTerminated) {		if(deviceListItem->deviceInterface) {			kr = (*deviceListItem->deviceInterface)->Release(deviceListItem->deviceInterface);		}		kr = IOObjectRelease(deviceListItem->notification);		ListResultItem_t* item = NULL;		if(deviceItem) {			item = CopyElement(&deviceItem->deviceParams);			RemoveItemFromList(deviceItem);			delete deviceItem;		}		else {			item = new ListResultItem_t();		}		WaitForDeviceHandled();		currentItem = item;		isAdded = false;		uv_async_send(&async_handler);	}}
开发者ID:apla,项目名称:node-usb-detection,代码行数:38,


示例22: pc_client_disconnect

/** * disconnect will make the uv loop to exit */void pc_client_disconnect(pc_client_t* client){  assert(client);  uv_mutex_lock(&client->state_mutex);  client->state = PC_ST_DISCONNECTING;  uv_mutex_unlock(&client->state_mutex);  uv_async_send(client->close_async);}
开发者ID:559210,项目名称:libpomelo,代码行数:10,


示例23: h2o_multithread_send_message

void h2o_multithread_send_message(h2o_multithread_receiver_t *receiver, h2o_multithread_message_t *message){    int do_send = 0;    pthread_mutex_lock(&receiver->queue->mutex);    if (message != NULL) {        assert(!h2o_linklist_is_linked(&message->link));        if (h2o_linklist_is_empty(&receiver->_messages)) {            h2o_linklist_unlink(&receiver->_link);            h2o_linklist_insert(&receiver->queue->receivers.active, &receiver->_link);            do_send = 1;        }        h2o_linklist_insert(&receiver->_messages, &message->link);    } else {        if (h2o_linklist_is_empty(&receiver->_messages))            do_send = 1;    }    pthread_mutex_unlock(&receiver->queue->mutex);    if (do_send) {#if H2O_USE_LIBUV        uv_async_send(&receiver->queue->async);#else        while (write(receiver->queue->async.write, "", 1) == -1 && errno == EINTR)            ;#endif    }}
开发者ID:ConfusedReality,项目名称:h2o,代码行数:28,


示例24: iotjs_tizen_bridge_native

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;}
开发者ID:Samsung,项目名称:iotjs,代码行数:28,


示例25: uv_async_send

void TCPClient::Close(){    if (isclosed_) {        return;    }    isuseraskforclosed_ = true;    uv_async_send(&async_handle_);}
开发者ID:Leon718,项目名称:simple_libuv_server,代码行数:8,


示例26: thread_cb

static void thread_cb(void* arg) {  unsigned i;  while (done == 0) {    i = fastrand() % ARRAY_SIZE(container->async_handles);    uv_async_send(container->async_handles + i);  }}
开发者ID:sjw7453584,项目名称:Server,代码行数:8,


示例27: uv_mutex_lock

void Workers::submit(const JobResult &result){    uv_mutex_lock(&m_mutex);    m_queue.push_back(result);    uv_mutex_unlock(&m_mutex);    uv_async_send(&m_async);}
开发者ID:mike2001,项目名称:xmrig,代码行数:8,


示例28: uv_eio_done_poll

static void uv_eio_done_poll(eio_channel *channel) {  /*   * Signal the main thread that we should stop calling eio_poll().   * from the idle watcher.   */  uv_loop_t* loop = channel->data;  uv_async_send(&loop->uv_eio_done_poll_notifier);}
开发者ID:AgeGuest,项目名称:node,代码行数:8,


示例29: uv_thread_self

// Request TLSConnection to close its connection.void TLSConnectionPrivate::Disconnect() {	unsigned long us = uv_thread_self();	unsigned long it = thread_id_.load();	if (us == it) {		Shutdown(TLS_CONNECTION_STATE_DISCONNECTED_LOCAL);	} else if (it > 0) {		uv_async_send(&dcasync_);	}}
开发者ID:dafoxia,项目名称:libmumble,代码行数:10,



注:本文中的uv_async_send函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ uv_buf_init函数代码示例
C++ uv_async_init函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。