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

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

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

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

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

示例1: cloexec_accept

/* * note: the socket must be in non-blocking mode, or the call might block while the mutex is being locked */int cloexec_accept(int socket, struct sockaddr *addr, socklen_t *addrlen){    int fd = -1;#ifndef _MSC_VER    pthread_mutex_lock(&cloexec_mutex);#else	uv_mutex_lock(&cloexec_mutex);#endif    if ((fd = accept(socket, addr, addrlen)) == -1)        goto Exit;    if (set_cloexec(fd) != 0) {        closesocket(fd);        fd = -1;        goto Exit;    }Exit:#ifndef _MSC_VER    pthread_mutex_unlock(&cloexec_mutex);#else	uv_mutex_unlock(&cloexec_mutex);#endif    return fd;}
开发者ID:LakhanRathi92,项目名称:h2o,代码行数:28,


示例2: pc_add_listener

int pc_add_listener(pc_client_t *client, const char *event,                    pc_event_cb event_cb) {  if(PC_ST_CLOSED == client->state) {    LOGD( "Pomelo client has closed./n");    return -1;  }  pc_listener_t *listener = pc_listener_new();  if(listener == NULL) {    LOGD( "Fail to create listener./n");    return -1;  }  listener->cb = event_cb;  uv_mutex_lock(&client->listener_mutex);  ngx_queue_t *head = pc_map_get(client->listeners, event);  if(head == NULL) {    head = (ngx_queue_t *)malloc(sizeof(ngx_queue_t));    if(head == NULL) {      LOGD( "Fail to create listener queue./n");      pc_listener_destroy(listener);      return -1;    }    ngx_queue_init(head);    pc_map_set(client->listeners, event, head);  }  ngx_queue_insert_tail(head, &listener->queue);  uv_mutex_unlock(&client->listener_mutex);  return 0;}
开发者ID:NewYuil,项目名称:libpomelo,代码行数:35,


示例3: uv_mutex_lock

void Adapter::cleanUpV8Resources(){    uv_mutex_lock(adapterCloseMutex);    if (asyncStatus != nullptr)    {        auto handle = reinterpret_cast<uv_handle_t *>(asyncStatus);        uv_close(handle, [](uv_handle_t *handle) {            delete handle;        });        this->statusCallback.reset();        asyncStatus = nullptr;    }    if (eventIntervalTimer != nullptr)    {        // Deallocate resources related to the event handling interval timer        if (uv_timer_stop(eventIntervalTimer) != 0)        {            std::terminate();        }        auto handle = reinterpret_cast<uv_handle_t *>(eventIntervalTimer);        uv_close(handle, [](uv_handle_t *handle)        {            delete handle;        });        eventIntervalTimer = nullptr;    }    if (asyncEvent != nullptr)    {        auto handle = reinterpret_cast<uv_handle_t *>(asyncEvent);        uv_close(handle, [](uv_handle_t *handle)        {            delete handle;        });        this->eventCallback.reset();        asyncEvent = nullptr;    }    if (asyncLog != nullptr)    {        auto logHandle = reinterpret_cast<uv_handle_t *>(asyncLog);        uv_close(logHandle, [](uv_handle_t *handle)        {            delete handle;        });        this->logCallback.reset();        asyncLog = nullptr;    }    uv_mutex_unlock(adapterCloseMutex);}
开发者ID:lbabaly,项目名称:pc-ble-driver-js,代码行数:59,


示例4: status_wait

int status_wait(Status* status, uint64_t timeout_secs) {  int count;  uv_mutex_lock(&status->mutex);  uv_cond_timedwait(&status->cond, &status->mutex, timeout_secs * 1000 * 1000 * 1000);  count = status->count;  uv_mutex_unlock(&status->mutex);  return count;}
开发者ID:Instagram,项目名称:cpp-driver,代码行数:8,


示例5: uv__custom_sem_trywait

static int uv__custom_sem_trywait(uv_sem_t* sem_) {  uv_semaphore_t* sem;  sem = *(uv_semaphore_t**)sem_;  if (uv_mutex_trylock(&sem->mutex) != 0)    return UV_EAGAIN;  if (sem->value == 0) {    uv_mutex_unlock(&sem->mutex);    return UV_EAGAIN;  }  sem->value--;  uv_mutex_unlock(&sem->mutex);  return 0;}
开发者ID:AustinShalit,项目名称:allwpilib,代码行数:17,


示例6: udprelay_close

voidudprelay_close(struct server_context *server) {    uv_poll_stop(&server->watcher);    close(server->udp_fd);    uv_mutex_lock(&mutex);    cache_removeall(cache, server->udp.loop, select_cb);    uv_mutex_unlock(&mutex);}
开发者ID:nsdown,项目名称:xsocks-1,代码行数:8,


示例7: 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,


示例8: WaitForDeviceHandled

static void WaitForDeviceHandled() {	uv_mutex_lock(&notify_mutex);	if(deviceHandled == false) {		uv_cond_wait(&notifyDeviceHandled, &notify_mutex);	}	deviceHandled = false;	uv_mutex_unlock(&notify_mutex);}
开发者ID:apla,项目名称:node-usb-detection,代码行数:8,


示例9: uv_key_get

void RecursiveLockGuard::release() {    void* lkey = uv_key_get(mutex_key);    if (lkey) {        uv_mutex_unlock(mutex);        uv_key_set(mutex_key, 0);    }    locked = false;}
开发者ID:javaos74,项目名称:opflex,代码行数:8,


示例10: pg_cache_punch_hole

/* * TODO: last waiter frees descriptor ? */void pg_cache_punch_hole(struct rrdengine_instance *ctx, struct rrdeng_page_cache_descr *descr){    struct page_cache *pg_cache = &ctx->pg_cache;    Pvoid_t *PValue;    struct pg_cache_page_index *page_index;    int ret;    uv_rwlock_rdlock(&pg_cache->metrics_index.lock);    PValue = JudyHSGet(pg_cache->metrics_index.JudyHS_array, descr->id, sizeof(uuid_t));    assert(NULL != PValue);    page_index = *PValue;    uv_rwlock_rdunlock(&pg_cache->metrics_index.lock);    uv_rwlock_wrlock(&page_index->lock);    ret = JudyLDel(&page_index->JudyL_array, (Word_t)(descr->start_time / USEC_PER_SEC), PJE0);    uv_rwlock_wrunlock(&page_index->lock);    if (unlikely(0 == ret)) {        error("Page under deletion was not in index.");        if (unlikely(debug_flags & D_RRDENGINE))            print_page_cache_descr(descr);        goto destroy;    }    assert(1 == ret);    uv_rwlock_wrlock(&pg_cache->pg_cache_rwlock);    ++ctx->stats.pg_cache_deletions;    --pg_cache->page_descriptors;    uv_rwlock_wrunlock(&pg_cache->pg_cache_rwlock);    uv_mutex_lock(&descr->mutex);    while (!pg_cache_try_get_unsafe(descr, 1)) {        debug(D_RRDENGINE, "%s: Waiting for locked page:", __func__);        if(unlikely(debug_flags & D_RRDENGINE))            print_page_cache_descr(descr);        pg_cache_wait_event_unsafe(descr);    }    /* even a locked page could be dirty */    while (unlikely(descr->flags & RRD_PAGE_DIRTY)) {        debug(D_RRDENGINE, "%s: Found dirty page, waiting for it to be flushed:", __func__);        if (unlikely(debug_flags & D_RRDENGINE))            print_page_cache_descr(descr);        pg_cache_wait_event_unsafe(descr);    }    uv_mutex_unlock(&descr->mutex);    if (descr->flags & RRD_PAGE_POPULATED) {        /* only after locking can it be safely deleted from LRU */        pg_cache_replaceQ_delete(ctx, descr);        uv_rwlock_wrlock(&pg_cache->pg_cache_rwlock);        pg_cache_evict_unsafe(ctx, descr);        uv_rwlock_wrunlock(&pg_cache->pg_cache_rwlock);    }    pg_cache_put(descr);destroy:    pg_cache_destroy_descr(descr);    pg_cache_update_metric_times(page_index);}
开发者ID:firehol,项目名称:netdata,代码行数:61,


示例11: graph_thread

// send data to the grapher app void graph_thread(void* user) {  Graph* g = static_cast<Graph*>(user);  int sock = nn_socket(AF_SP, NN_PUSH);  if(sock == -1) {    printf("error: cannot create client socket./n");    return;  }  int rc = nn_connect(sock, g->address.c_str());  if(rc < 0) {    printf("error: cannot connect, %s/n", nn_strerror(errno));    return;  }  std::vector<GraphPacket*> todo;  while(true) {        // get the work!    uv_mutex_lock(&g->mutex);    {      while(g->work.size() == 0) {        uv_cond_wait(&g->cv, &g->mutex);      }      std::copy(g->work.begin(), g->work.end(), std::back_inserter(todo));      g->work.clear();    }    uv_mutex_unlock(&g->mutex);    // perform work    bool must_stop = false;    for(std::vector<GraphPacket*>::iterator it = todo.begin(); it != todo.end(); ++it) {      GraphPacket* p = *it;      if(p->data[0] == PKT_TYPE_STOP) {        must_stop = true;        break;      }      else {        int rc = nn_send(sock, (char*)&p->data.front(), p->data.size(), 0);        if(rc < 0) {          printf("error: cannot send to grapher: %s/n", nn_strerror(rc));        }      }      delete p;      p = NULL;    } // for    todo.clear();    if(must_stop) {      break;    }  }  printf("@todo -> cleanup socket./n");}
开发者ID:AlexSnet,项目名称:video_streamer,代码行数:59,


示例12: worker

static void worker(void* arg) {  printf("worker/n");  worker_config* wc = (worker_config*) arg;  uv_mutex_lock(&wc->mutex);  uv_cond_signal(&wc->cond);  uv_mutex_unlock(&wc->mutex);}
开发者ID:rwaldron,项目名称:libuv-examples,代码行数:9,


示例13: uv_mutex_lock

void EventStream::add(Event * event) {  uv_mutex_lock(&mutex);  eventVector.push_back(event);  uv_ref(reinterpret_cast<uv_handle_t *>(&async));  uv_mutex_unlock(&mutex);  uv_async_send(&async);}
开发者ID:mross-pivotal,项目名称:node-gemfire,代码行数:9,


示例14: nub_thread_dispose

void nub_thread_dispose(nub_thread_t* thread, nub_thread_disposed_cb cb) {  thread->disposed = 1;  thread->disposed_cb_ = cb;  thread->nubloop->disposed_ = 1;  uv_mutex_lock(&thread->nubloop->thread_dispose_lock_);  fuq_enqueue(&thread->nubloop->thread_dispose_queue_, thread);  uv_mutex_unlock(&thread->nubloop->thread_dispose_lock_);  uv_async_send(thread->nubloop->work_ping_);}
开发者ID:nubjs,项目名称:libnub,代码行数:9,


示例15: wait_exit

void wait_exit() {  uv_mutex_lock(&mutex);  while (close_future == NULL) {    uv_cond_wait(&cond, &mutex);  }  uv_mutex_unlock(&mutex);  cass_future_wait(close_future);  cass_future_free(close_future);}
开发者ID:Ilceren,项目名称:cpp-driver,代码行数:9,


示例16: iobuf_remove

void iobuf_remove(struct iobuf_t *io, size_t n) {	uv_mutex_lock(&io->lock);  if(n > 0 && n <= io->len) {    memmove(io->buf, io->buf + n, io->len - n);    io->len -= n;		io->buf[io->len] = 0;  }	uv_mutex_unlock(&io->lock);}
开发者ID:pilight,项目名称:pilight,代码行数:9,


示例17: signal_exit

void signal_exit(CassSession* session) {  uv_mutex_lock(&mutex);  if (session) {    close_future = cass_session_close(session);  }  exit_flag = 1;  uv_cond_signal(&cond);  uv_mutex_unlock(&mutex);}
开发者ID:Instagram,项目名称:cpp-driver,代码行数:9,


示例18: uv_chan_send

void uv_chan_send(uv_chan_t *chan, void *data) {    uv__chan_item_t *item = (uv__chan_item_t *)malloc(sizeof(uv__chan_item_t));    item->data = data;    uv_mutex_lock(&chan->mutex);    QUEUE_INSERT_TAIL(&chan->q, &item->active_queue);    uv_cond_signal(&chan->cond);    uv_mutex_unlock(&chan->mutex);}
开发者ID:Dickordia,项目名称:mapbox-gl-native,代码行数:9,


示例19: rtb_window_unlock

voidrtb_window_unlock(struct rtb_window *rwin){    struct xrtb_window *self = RTB_WINDOW_AS(rwin, xrtb_window);    glXMakeContextCurrent(self->xrtb->dpy, None, None, NULL);    XUnlockDisplay(self->xrtb->dpy);    uv_mutex_unlock(&self->lock);}
开发者ID:kristiandelay,项目名称:rutabaga,代码行数:9,


示例20: lock_callback

static void lock_callback(int mode, int type, const char *file, int line){	if (mode & CRYPTO_LOCK) {		uv_mutex_lock(&(g_pMutex[type]));	}	else {		uv_mutex_unlock(&(g_pMutex[type]));	}}
开发者ID:shshheyi,项目名称:XTransServer,代码行数:9,


示例21: printf

bool Kinect::setup() {  if(ctx) {    printf("Error: the freenect context has been setup already./n");    return false;  }  if(freenect_init(&ctx, NULL) < 0) {    printf("Error: cannot init libfreenect./n");    return false;  }  freenect_set_log_level(ctx, FREENECT_LOG_DEBUG);  int ndevices = freenect_num_devices(ctx);  if(ndevices < 1) {    printf("Error: cannot find a kinect. @todo cleanup mem./n");    freenect_shutdown(ctx);    ctx = NULL;    return false;  }  printf("Number of found kinect devices: %d/n", ndevices);  freenect_select_subdevices(ctx, (freenect_device_flags)(FREENECT_DEVICE_MOTOR | FREENECT_DEVICE_CAMERA));  //freenect_select_subdevices(ctx, (freenect_device_flags)( FREENECT_DEVICE_CAMERA));  int devnum = 0;  if(freenect_open_device(ctx, &device, devnum) < 0) {    printf("Error: cannot open device: %d/n", devnum);    freenect_shutdown(ctx);    ctx = NULL;    return false;  }  freenect_set_user(device, this);  uint32_t w = 640;  uint32_t h = 480;  uint32_t nbytes = w * h * 3;  nbytes_rgb = nbytes;  rgb_back = new uint8_t[nbytes];  rgb_mid = new uint8_t[nbytes];  rgb_front = new uint8_t[nbytes];  depth_back = new uint8_t[nbytes];  depth_mid = new uint8_t[nbytes];  depth_front = new uint8_t[nbytes];  uv_mutex_lock(&mutex);    must_stop = false;  uv_mutex_unlock(&mutex);  uv_thread_create(&thread, kinect_thread, this);  return true;}
开发者ID:HellicarAndLewis,项目名称:Swnt,代码行数:56,


示例22: uv_mutex_lock

int CAudioDecoder::put(cc_src_sample_t buf){	int ret = 0;	uv_mutex_lock(&queue_mutex);	if (buf_deque.size() > 50){		uv_mutex_unlock(&queue_mutex);		free(buf.buf);		return ret;	}	buf_deque.push_back(buf);	iFrame++;	uv_mutex_unlock(&queue_mutex);	uv_cond_signal(&queue_not_empty);	if (!bOpen && buf_deque.size() > 0){		open();	}	return ret;}
开发者ID:zhifeichen,项目名称:libcapture,代码行数:19,


示例23: MVM_dll_find_symbol

MVMObject * MVM_dll_find_symbol(MVMThreadContext *tc, MVMString *lib,        MVMString *sym) {    MVMDLLRegistry *entry;    MVMDLLSym *obj;    char *csym;    void *address;    uv_mutex_lock(&tc->instance->mutex_dll_registry);    MVM_string_flatten(tc, lib);    MVM_HASH_GET(tc, tc->instance->dll_registry, lib, entry);    if (!entry) {        uv_mutex_unlock(&tc->instance->mutex_dll_registry);        MVM_exception_throw_adhoc(tc,                "cannot find symbol in non-existent library");    }    if (!entry->lib) {        uv_mutex_unlock(&tc->instance->mutex_dll_registry);        MVM_exception_throw_adhoc(tc,                "cannot find symbol in unloaded library");    }    csym = MVM_string_utf8_encode_C_string(tc, sym);    address = dlFindSymbol(entry->lib, csym);    free(csym);    if (!address) {        uv_mutex_unlock(&tc->instance->mutex_dll_registry);        return NULL;    }    obj = (MVMDLLSym *)MVM_repr_alloc_init(tc,            tc->instance->raw_types.RawDLLSym);    obj->body.address = address;    obj->body.dll = entry;    entry->refcount++;    uv_mutex_unlock(&tc->instance->mutex_dll_registry);    return (MVMObject *)obj;}
开发者ID:dagurval,项目名称:MoarVM,代码行数:43,


示例24: async_cb

static void async_cb(uv_async_t *handle){  Loop *l = handle->loop->data;  uv_mutex_lock(&l->mutex);  while (!multiqueue_empty(l->thread_events)) {    Event ev = multiqueue_get(l->thread_events);    multiqueue_put_event(l->fast_events, ev);  }  uv_mutex_unlock(&l->mutex);}
开发者ID:fatbird,项目名称:neovim,代码行数:10,


示例25: uv__custom_sem_post

static void uv__custom_sem_post(uv_sem_t* sem_) {  uv_semaphore_t* sem;  sem = *(uv_semaphore_t**)sem_;  uv_mutex_lock(&sem->mutex);  sem->value++;  if (sem->value == 1)    uv_cond_signal(&sem->cond);  uv_mutex_unlock(&sem->mutex);}
开发者ID:AustinShalit,项目名称:allwpilib,代码行数:10,


示例26: _dynlock_lock_callback

static void_dynlock_lock_callback (int mode, CRYPTO_dynlock_value* self, const char* file, int line){	if (mode & CRYPTO_LOCK) {		uv_mutex_lock(self->lock);	}	else {		uv_mutex_unlock(self->lock);	}}
开发者ID:postfix,项目名称:libtor,代码行数:10,


示例27: uv__custom_sem_wait

static void uv__custom_sem_wait(uv_sem_t* sem_) {  uv_semaphore_t* sem;  sem = *(uv_semaphore_t**)sem_;  uv_mutex_lock(&sem->mutex);  while (sem->value == 0)    uv_cond_wait(&sem->cond, &sem->mutex);  sem->value--;  uv_mutex_unlock(&sem->mutex);}
开发者ID:AustinShalit,项目名称:allwpilib,代码行数:10,



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


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