summaryrefslogtreecommitdiffstats
path: root/src/lib/mt/Mutex.h
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@ubuntu.com>2018-04-25 18:07:30 -0400
committerLibravatarUnit 193 <unit193@ubuntu.com>2018-04-25 18:07:30 -0400
commit9b1b081cfdb1c0fb6457278775e0823f8bc10f62 (patch)
treece8840148d8445055ba9e4f12263b2208f234c16 /src/lib/mt/Mutex.h
Import Upstream version 2.0.0+dfsgupstream/2.0.0+dfsg
Diffstat (limited to 'src/lib/mt/Mutex.h')
-rw-r--r--src/lib/mt/Mutex.h79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/lib/mt/Mutex.h b/src/lib/mt/Mutex.h
new file mode 100644
index 0000000..51a9649
--- /dev/null
+++ b/src/lib/mt/Mutex.h
@@ -0,0 +1,79 @@
+/*
+ * barrier -- mouse and keyboard sharing utility
+ * Copyright (C) 2012-2016 Symless Ltd.
+ * Copyright (C) 2002 Chris Schoeneman
+ *
+ * This package is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * found in the file LICENSE that should have accompanied this file.
+ *
+ * This package is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include "arch/IArchMultithread.h"
+
+//! Mutual exclusion
+/*!
+A non-recursive mutual exclusion object. Only one thread at a time can
+hold a lock on a mutex. Any thread that attempts to lock a locked mutex
+will block until the mutex is unlocked. At that time, if any threads are
+blocked, exactly one waiting thread will acquire the lock and continue
+running. A thread may not lock a mutex it already owns the lock on; if
+it tries it will deadlock itself.
+*/
+class Mutex {
+public:
+ Mutex();
+ //! Equivalent to default c'tor
+ /*!
+ Copy c'tor doesn't copy anything. It just makes it possible to
+ copy objects that contain a mutex.
+ */
+ Mutex(const Mutex&);
+ ~Mutex();
+
+ //! @name manipulators
+ //@{
+
+ //! Does nothing
+ /*!
+ This does nothing. It just makes it possible to assign objects
+ that contain a mutex.
+ */
+ Mutex& operator=(const Mutex&);
+
+ //@}
+ //! @name accessors
+ //@{
+
+ //! Lock the mutex
+ /*!
+ Locks the mutex, which must not have been previously locked by the
+ calling thread. This blocks if the mutex is already locked by another
+ thread.
+
+ (cancellation point)
+ */
+ void lock() const;
+
+ //! Unlock the mutex
+ /*!
+ Unlocks the mutex, which must have been previously locked by the
+ calling thread.
+ */
+ void unlock() const;
+
+ //@}
+
+private:
+ friend class CondVarBase;
+ ArchMutex m_mutex;
+};