diff options
author | Tor Egge <Tor.Egge@broadpark.no> | 2017-11-12 21:47:27 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@broadpark.no> | 2017-11-12 21:47:27 +0100 |
commit | 10f161cc4a813f01b7011581601dfb4012b1d202 (patch) | |
tree | 46927dc51877f4727ac8e620b1071df07c3fd8fd | |
parent | 7dc5186f858d59686bf2f0ceb052ccd5e30ada38 (diff) |
Use std::lock_guard instead of std::unique_lock.
-rw-r--r-- | fnet/src/vespa/fnet/connection.cpp | 8 | ||||
-rw-r--r-- | fnet/src/vespa/fnet/frt/invoker.cpp | 2 | ||||
-rw-r--r-- | fnet/src/vespa/fnet/iocomponent.cpp | 4 | ||||
-rw-r--r-- | fnet/src/vespa/fnet/packetqueue.cpp | 4 | ||||
-rw-r--r-- | fnet/src/vespa/fnet/scheduler.cpp | 8 | ||||
-rw-r--r-- | fnet/src/vespa/fnet/transport_thread.cpp | 14 |
6 files changed, 20 insertions, 20 deletions
diff --git a/fnet/src/vespa/fnet/connection.cpp b/fnet/src/vespa/fnet/connection.cpp index f2a4ab3a23d..ff6c1ab0b1d 100644 --- a/fnet/src/vespa/fnet/connection.cpp +++ b/fnet/src/vespa/fnet/connection.cpp @@ -45,7 +45,7 @@ public: void SyncPacket::Free() { - std::unique_lock<std::mutex> guard(_lock); + std::lock_guard<std::mutex> guard(_lock); _done = true; if (_waiting) { _cond.notify_one(); @@ -560,7 +560,7 @@ FNET_Connection::OpenChannel() uint32_t chid; { - std::unique_lock<std::mutex> guard(_ioc_lock); + std::lock_guard<std::mutex> guard(_ioc_lock); chid = GetNextID(); AddRef_NoLock(); } @@ -652,7 +652,7 @@ FNET_Connection::PostPacket(FNET_Packet *packet, uint32_t chid) uint32_t FNET_Connection::GetQueueLen() { - std::unique_lock<std::mutex> guard(_ioc_lock); + std::lock_guard<std::mutex> guard(_ioc_lock); return _queue.GetPacketCnt_NoLock() + _myQueue.GetPacketCnt_NoLock(); } @@ -710,7 +710,7 @@ FNET_Connection::HandleReadEvent() bool FNET_Connection::writePendingAfterConnect() { - std::unique_lock<std::mutex> guard(_ioc_lock); + std::lock_guard<std::mutex> guard(_ioc_lock); _state = FNET_CONNECTED; // SetState(FNET_CONNECTED) LOG(debug, "Connection(%s): State transition: %s -> %s", GetSpec(), GetStateString(FNET_CONNECTING), GetStateString(FNET_CONNECTED)); diff --git a/fnet/src/vespa/fnet/frt/invoker.cpp b/fnet/src/vespa/fnet/frt/invoker.cpp index 5afc355c68f..ce4daa988de 100644 --- a/fnet/src/vespa/fnet/frt/invoker.cpp +++ b/fnet/src/vespa/fnet/frt/invoker.cpp @@ -32,7 +32,7 @@ void FRT_SingleReqWait::RequestDone(FRT_RPCRequest *req) { (void) req; - std::unique_lock<std::mutex> guard(_lock); + std::lock_guard<std::mutex> guard(_lock); _done = true; if (_waiting) { _cond.notify_one(); diff --git a/fnet/src/vespa/fnet/iocomponent.cpp b/fnet/src/vespa/fnet/iocomponent.cpp index ec51c1f080e..8276da57e2e 100644 --- a/fnet/src/vespa/fnet/iocomponent.cpp +++ b/fnet/src/vespa/fnet/iocomponent.cpp @@ -48,7 +48,7 @@ FNET_IOComponent::UpdateTimeOut() { void FNET_IOComponent::AddRef() { - std::unique_lock<std::mutex> guard(_ioc_lock); + std::lock_guard<std::mutex> guard(_ioc_lock); assert(_ioc_refcnt > 0); _ioc_refcnt++; } @@ -66,7 +66,7 @@ void FNET_IOComponent::SubRef() { { - std::unique_lock<std::mutex> guard(_ioc_lock); + std::lock_guard<std::mutex> guard(_ioc_lock); assert(_ioc_refcnt > 0); if (--_ioc_refcnt > 0) { return; diff --git a/fnet/src/vespa/fnet/packetqueue.cpp b/fnet/src/vespa/fnet/packetqueue.cpp index 4fdb5842a9d..4331819d3f5 100644 --- a/fnet/src/vespa/fnet/packetqueue.cpp +++ b/fnet/src/vespa/fnet/packetqueue.cpp @@ -192,7 +192,7 @@ void FNET_PacketQueue::QueuePacket(FNET_Packet *packet, FNET_Context context) { assert(packet != nullptr); - std::unique_lock<std::mutex> guard(_lock); + std::lock_guard<std::mutex> guard(_lock); EnsureFree(); _buf[_in_pos]._packet = packet; // insert packet ref. _buf[_in_pos]._context = context; @@ -257,7 +257,7 @@ FNET_PacketQueue::DequeuePacket(uint32_t maxwait, FNET_Context *context) void FNET_PacketQueue::Print(uint32_t indent) { - std::unique_lock<std::mutex> guard(_lock); + std::lock_guard<std::mutex> guard(_lock); uint32_t i = _out_pos; uint32_t cnt = _bufused; diff --git a/fnet/src/vespa/fnet/scheduler.cpp b/fnet/src/vespa/fnet/scheduler.cpp index ef67407cb44..6c8340c1ff8 100644 --- a/fnet/src/vespa/fnet/scheduler.cpp +++ b/fnet/src/vespa/fnet/scheduler.cpp @@ -40,7 +40,7 @@ FNET_Scheduler::~FNET_Scheduler() bool empty = true; std::stringstream dump; { - std::unique_lock<std::mutex> guard(_lock); + std::lock_guard<std::mutex> guard(_lock); dump << "FNET_Scheduler {" << std::endl; dump << " [slot=" << _currSlot << "][iter=" << _currIter << "]" << std::endl; for (int i = 0; i <= NUM_SLOTS; i++) { @@ -70,7 +70,7 @@ FNET_Scheduler::Schedule(FNET_Task *task, double seconds) { uint32_t ticks = 1 + (uint32_t) (seconds * (1000 / SLOT_TICK) + 0.5); - std::unique_lock<std::mutex> guard(_lock); + std::lock_guard<std::mutex> guard(_lock); if (!task->_killed) { if (IsActive(task)) LinkOut(task); @@ -84,7 +84,7 @@ FNET_Scheduler::Schedule(FNET_Task *task, double seconds) void FNET_Scheduler::ScheduleNow(FNET_Task *task) { - std::unique_lock<std::mutex> guard(_lock); + std::lock_guard<std::mutex> guard(_lock); if (!task->_killed) { if (IsActive(task)) LinkOut(task); @@ -119,7 +119,7 @@ FNET_Scheduler::Kill(FNET_Task *task) void FNET_Scheduler::Print(FILE *dst) { - std::unique_lock<std::mutex> guard(_lock); + std::lock_guard<std::mutex> guard(_lock); fprintf(dst, "FNET_Scheduler {\n"); fprintf(dst, " [slot=%d][iter=%d]\n", _currSlot, _currIter); for (int i = 0; i <= NUM_SLOTS; i++) { diff --git a/fnet/src/vespa/fnet/transport_thread.cpp b/fnet/src/vespa/fnet/transport_thread.cpp index 61fcc26f1c6..443c90f1af4 100644 --- a/fnet/src/vespa/fnet/transport_thread.cpp +++ b/fnet/src/vespa/fnet/transport_thread.cpp @@ -173,7 +173,7 @@ FNET_TransportThread::UpdateStats() comp->FlushDirectWriteStats(); } { - std::unique_lock<std::mutex> guard(_lock); + std::lock_guard<std::mutex> guard(_lock); _stats.Update(&_counters, ms / 1000.0); } _counters.Clear(); @@ -238,7 +238,7 @@ FNET_TransportThread::FNET_TransportThread(FNET_Transport &owner_in) FNET_TransportThread::~FNET_TransportThread() { { - std::unique_lock<std::mutex> guard(_lock); + std::lock_guard<std::mutex> guard(_lock); _deleted = true; } if (_started && !_finished) { @@ -379,7 +379,7 @@ FNET_TransportThread::ShutDown(bool waitFinished) { bool wasEmpty = false; { - std::unique_lock<std::mutex> guard(_lock); + std::lock_guard<std::mutex> guard(_lock); if (!_shutdown) { _shutdown = true; wasEmpty = _queue.IsEmpty_NoLock(); @@ -413,7 +413,7 @@ FNET_TransportThread::InitEventLoop() bool wasStarted; bool wasDeleted; { - std::unique_lock<std::mutex> guard(_lock); + std::lock_guard<std::mutex> guard(_lock); wasStarted = _started; wasDeleted = _deleted; if (!_started && !_deleted) { @@ -440,7 +440,7 @@ void FNET_TransportThread::handle_wakeup() { { - std::unique_lock<std::mutex> guard(_lock); + std::lock_guard<std::mutex> guard(_lock); CountEvent(_queue.FlushPackets_NoLock(&_myQueue)); } @@ -590,7 +590,7 @@ FNET_TransportThread::EventLoopIteration() // flush event queue { - std::unique_lock<std::mutex> guard(_lock); + std::lock_guard<std::mutex> guard(_lock); _queue.FlushPackets_NoLock(&_myQueue); } @@ -623,7 +623,7 @@ FNET_TransportThread::EventLoopIteration() _myQueue.IsEmpty_NoLock()); { - std::unique_lock<std::mutex> guard(_lock); + std::lock_guard<std::mutex> guard(_lock); _finished = true; if (_waitFinished) { _cond.notify_all(); |