当前位置: 首页>>代码示例>>C++>>正文


C++ unique_lock::unlock方法代码示例

本文整理汇总了C++中std::unique_lock::unlock方法的典型用法代码示例。如果您正苦于以下问题:C++ unique_lock::unlock方法的具体用法?C++ unique_lock::unlock怎么用?C++ unique_lock::unlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::unique_lock的用法示例。


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

示例1: maybe_notify

	void alert_manager::maybe_notify(alert* a, std::unique_lock<std::mutex>& lock)
	{
		if (m_alerts[m_generation].size() == 1)
		{
			lock.unlock();

			// we just posted to an empty queue. If anyone is waiting for
			// alerts, we need to notify them. Also (potentially) call the
			// user supplied m_notify callback to let the client wake up its
			// message loop to poll for alerts.
			if (m_notify) m_notify();

			// TODO: 2 keep a count of the number of threads waiting. Only if it's
			// > 0 notify them
			m_condition.notify_all();
		}
		else
		{
			lock.unlock();
		}

#ifndef TORRENT_DISABLE_EXTENSIONS
		for (auto& e : m_ses_extensions)
			e->on_alert(a);
#else
		TORRENT_UNUSED(a);
#endif
	}
开发者ID:digideskio,项目名称:libtorrent,代码行数:28,代码来源:alert_manager.cpp

示例2: DeviceCmdSetMode

CS_StatusValue UsbCameraImpl::DeviceCmdSetMode(
    std::unique_lock<wpi::mutex>& lock, const Message& msg) {
  VideoMode newMode;
  if (msg.kind == Message::kCmdSetMode) {
    newMode.pixelFormat = msg.data[0];
    newMode.width = msg.data[1];
    newMode.height = msg.data[2];
    newMode.fps = msg.data[3];
    m_modeSetPixelFormat = true;
    m_modeSetResolution = true;
    m_modeSetFPS = true;
  } else if (msg.kind == Message::kCmdSetPixelFormat) {
    newMode = m_mode;
    newMode.pixelFormat = msg.data[0];
    m_modeSetPixelFormat = true;
  } else if (msg.kind == Message::kCmdSetResolution) {
    newMode = m_mode;
    newMode.width = msg.data[0];
    newMode.height = msg.data[1];
    m_modeSetResolution = true;
  } else if (msg.kind == Message::kCmdSetFPS) {
    newMode = m_mode;
    newMode.fps = msg.data[0];
    m_modeSetFPS = true;
  }

  // If the pixel format or resolution changed, we need to disconnect and
  // reconnect
  if (newMode.pixelFormat != m_mode.pixelFormat ||
      newMode.width != m_mode.width || newMode.height != m_mode.height) {
    m_mode = newMode;
    lock.unlock();
    bool wasStreaming = m_streaming;
    if (wasStreaming) DeviceStreamOff();
    if (m_fd >= 0) {
      DeviceDisconnect();
      DeviceConnect();
    }
    if (wasStreaming) DeviceStreamOn();
    Notifier::GetInstance().NotifySourceVideoMode(*this, newMode);
    lock.lock();
  } else if (newMode.fps != m_mode.fps) {
    m_mode = newMode;
    lock.unlock();
    // Need to stop streaming to set FPS
    bool wasStreaming = m_streaming;
    if (wasStreaming) DeviceStreamOff();
    DeviceSetFPS();
    if (wasStreaming) DeviceStreamOn();
    Notifier::GetInstance().NotifySourceVideoMode(*this, newMode);
    lock.lock();
  }

  return CS_OK;
}
开发者ID:FRCTeam1967,项目名称:FRCTeam1967,代码行数:55,代码来源:UsbCameraImpl.cpp

示例3: stop_client

void F::stop_client (std::unique_lock <std::mutex> &lock)
{
  bool wasLocked;

  if (lock) {
    wasLocked = true;
  }

  if (!wasLocked) {
    lock.lock();
  }

  if (client) {
    client->stop();
  }

  terminate = true;

  lock.unlock();

  GST_DEBUG ("Waiting for client thread to finish");
  clientThread.join();

  if (wasLocked) {
    lock.lock();
  }
}
开发者ID:ArenaCloud,项目名称:kurento-media-server,代码行数:27,代码来源:BaseTest.cpp

示例4: handle_reconnect

 void handle_reconnect(std::unique_lock<std::mutex>& lock, SyncSession& session) const override
 {
     // Ask the binding to retry getting the token for this session.
     std::shared_ptr<SyncSession> session_ptr = session.shared_from_this();
     lock.unlock();
     session.m_config.bind_session_handler(session_ptr->m_realm_path, session_ptr->m_config, session_ptr);
 }
开发者ID:AlanAherne,项目名称:BabyTunes,代码行数:7,代码来源:sync_session.cpp

示例5: push_and_notify_

 channel_op_status push_and_notify_( ptr_t new_node,
                                     std::unique_lock< mutex > & lk) noexcept {
     push_tail_( new_node);
     lk.unlock();
     not_empty_cond_.notify_one();
     return channel_op_status::success;
 }
开发者ID:tempbottle,项目名称:boost-fiber,代码行数:7,代码来源:unbounded_channel.hpp

示例6: deallocateXLarge

void Heap::deallocateXLarge(std::unique_lock<StaticMutex>& lock, void* object)
{
    Range toDeallocate = m_xLargeObjects.pop(&findXLarge(lock, object));

    lock.unlock();
    vmDeallocate(toDeallocate.begin(), toDeallocate.size());
    lock.lock();
}
开发者ID:rhythmkay,项目名称:webkit,代码行数:8,代码来源:Heap.cpp

示例7: access_token_expired

 bool access_token_expired(std::unique_lock<std::mutex>& lock, SyncSession& session) const override
 {
     session.advance_state(lock, waiting_for_access_token);
     std::shared_ptr<SyncSession> session_ptr = session.shared_from_this();
     lock.unlock();
     session.m_config.bind_session_handler(session_ptr->m_realm_path, session_ptr->m_config, session_ptr);
     return false;
 }
开发者ID:gerlandiolucena,项目名称:iosvisits,代码行数:8,代码来源:sync_session.cpp

示例8: unregister

void SyncSession::unregister(std::unique_lock<std::mutex>& lock)
{
    REALM_ASSERT(lock.owns_lock());
    REALM_ASSERT(m_state == &State::inactive); // Must stop an active session before unregistering.

    lock.unlock();
    SyncManager::shared().unregister_session(m_realm_path);
}
开发者ID:gerlandiolucena,项目名称:iosvisits,代码行数:8,代码来源:sync_session.cpp

示例9: finishRelease

void PageInfo::finishRelease(std::unique_lock<std::mutex> lock) {
	delete[] p_buffer;
	
	lock.unlock();
	p_cache->p_cacheHost->afterRelease(this);
	lock.lock();
	
	if(p_waitQueue.empty()) {
		auto iterator = p_cache->p_presentPages.find(p_number);
		assert(iterator != p_cache->p_presentPages.end());
		p_cache->p_presentPages.erase(iterator);
		delete this;
	}else{
		lock.unlock();
		p_cache->p_cacheHost->requestAcquire(this);
	}
}
开发者ID:avdgrinten,项目名称:d3b,代码行数:17,代码来源:page-cache.cpp

示例10: pushConnection

 // helper for releasing connection and placing it in pool
 inline void pushConnection( std::unique_lock<std::mutex> &locker, ConPool &pool, redisConnection* con )
 {
     pool.second.push(con);
     locker.unlock();
     // notify other threads for their wake up in case of they are waiting
     // about empty connection queue
     pool.first.notify_one();
 }
开发者ID:everydayiplay,项目名称:cpp-hiredis-cluster,代码行数:9,代码来源:threadpool.cpp

示例11: schedule

void RepeatedTimerTask::schedule(std::unique_lock<raft_mutex_t>& lck) {
    _next_duetime =
            butil::milliseconds_from_now(adjust_timeout_ms(_timeout_ms));
    if (bthread_timer_add(&_timer, _next_duetime, on_timedout, this) != 0) {
        lck.unlock();
        LOG(ERROR) << "Fail to add timer";
        return on_timedout(this);
    }
}
开发者ID:ctero-graham,项目名称:braft,代码行数:9,代码来源:repeated_timer_task.cpp

示例12: resume

void SingleTaskScheduler::resume(std::unique_lock<Spinlock> lock) {
    assert(task_->status == Suspended || task_->status == Listening);
    assert(!task_->scheduled);
    task_->status = Running;
    task_->scheduled = false;
    task_->resumes += 1;
    resumed.store(true, std::memory_order_release);
    lock.unlock();
}
开发者ID:Strongc,项目名称:fiberize,代码行数:9,代码来源:singletaskscheduler.cpp

示例13: FindNextEventInternal

bool Listener::FindNextEventInternal(
    std::unique_lock<std::mutex> &lock,
    Broadcaster *broadcaster,             // nullptr for any broadcaster
    const ConstString *broadcaster_names, // nullptr for any event
    uint32_t num_broadcaster_names, uint32_t event_type_mask, EventSP &event_sp,
    bool remove) {
  // NOTE: callers of this function must lock m_events_mutex using a
  // Mutex::Locker
  // and pass the locker as the first argument. m_events_mutex is no longer
  // recursive.
  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EVENTS));

  if (m_events.empty())
    return false;

  Listener::event_collection::iterator pos = m_events.end();

  if (broadcaster == nullptr && broadcaster_names == nullptr &&
      event_type_mask == 0) {
    pos = m_events.begin();
  } else {
    pos = std::find_if(m_events.begin(), m_events.end(),
                       EventMatcher(broadcaster, broadcaster_names,
                                    num_broadcaster_names, event_type_mask));
  }

  if (pos != m_events.end()) {
    event_sp = *pos;

    if (log != nullptr)
      log->Printf("%p '%s' Listener::FindNextEventInternal(broadcaster=%p, "
                  "broadcaster_names=%p[%u], event_type_mask=0x%8.8x, "
                  "remove=%i) event %p",
                  static_cast<void *>(this), GetName(),
                  static_cast<void *>(broadcaster),
                  static_cast<const void *>(broadcaster_names),
                  num_broadcaster_names, event_type_mask, remove,
                  static_cast<void *>(event_sp.get()));

    if (remove) {
      m_events.erase(pos);
      // Unlock the event queue here.  We've removed this event and are about to
      // return
      // it so it should be okay to get the next event off the queue here - and
      // it might
      // be useful to do that in the "DoOnRemoval".
      lock.unlock();
      event_sp->DoOnRemoval();
    }
    return true;
  }

  event_sp.reset();
  return false;
}
开发者ID:2trill2spill,项目名称:freebsd,代码行数:55,代码来源:Listener.cpp

示例14: UnlockAndFlushToBodyReader

int HttpMessage::UnlockAndFlushToBodyReader(std::unique_lock<butil::Mutex>& mu) {
    if (_body.empty()) {
        mu.unlock();
        return 0;
    }
    butil::IOBuf body_seen = _body.movable();
    ProgressiveReader* r = _body_reader;
    mu.unlock();
    for (size_t i = 0; i < body_seen.backing_block_num(); ++i) {
        butil::StringPiece blk = body_seen.backing_block(i);
        butil::Status st = r->OnReadOnePart(blk.data(), blk.size());
        if (!st.ok()) {
            mu.lock();
            _body_reader = NULL;
            mu.unlock();
            r->OnEndOfMessage(st);
            return -1;
        }
    }
    return 0;
}
开发者ID:yzhenma,项目名称:brpc,代码行数:21,代码来源:http_message.cpp

示例15: runItemWithoutLock

void WorkQueue::runItemWithoutLock(std::unique_lock<std::mutex> &lock) {
    Item item = std::move(item_heap.front());
    std::pop_heap(std::begin(item_heap), std::end(item_heap));
    item_heap.pop_back();

    idle_flag = false;
    lock.unlock();
    item.func();
    lock.lock();
    idle_flag = true;
    cond.notify_all();
}
开发者ID:matthewbot,项目名称:Kube,代码行数:12,代码来源:WorkQueue.cpp


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