Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Loading...
Searching...
No Matches
scoped_lock.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 Roc Streaming authors
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 */
8
9//! @file roc_core/scoped_lock.h
10//! @brief RAII mutex lock.
11
12#ifndef ROC_CORE_SCOPED_LOCK_H_
13#define ROC_CORE_SCOPED_LOCK_H_
14
16
17namespace roc {
18namespace core {
19
20//! RAII mutex lock.
21template <class Mutex> class ScopedLock : NonCopyable<> {
22public:
23 //! Lock.
24 explicit ScopedLock(const Mutex& mutex)
25 : mutex_(mutex) {
26 mutex_.lock();
27 }
28
29 //! Unlock.
31 mutex_.unlock();
32 }
33
34private:
35 const Mutex& mutex_;
36};
37
38} // namespace core
39} // namespace roc
40
41#endif // ROC_CORE_SCOPED_LOCK_H_
Base class for non-copyable objects.
Definition noncopyable.h:23
RAII mutex lock.
Definition scoped_lock.h:21
ScopedLock(const Mutex &mutex)
Lock.
Definition scoped_lock.h:24
Shared ownership intrusive pointer.
Definition shared_ptr.h:32
Root namespace.
Non-copyable object.