summaryrefslogtreecommitdiff
path: root/thread.h
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2018-03-04 11:31:21 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2018-03-04 11:31:21 +0100
commit75648e80cfb13ee0589b246c4c0238b5e7c99abd (patch)
tree2e0019867d7bf6ef7052ec680a775af16f365dd5 /thread.h
parent8a7540321d01a11f461b99fc313e463ba58a5f65 (diff)
downloadvdr-75648e80cfb13ee0589b246c4c0238b5e7c99abd.tar.gz
vdr-75648e80cfb13ee0589b246c4c0238b5e7c99abd.tar.bz2
Modified cStateLock's SetExplicitModify() and IncState()
Diffstat (limited to 'thread.h')
-rw-r--r--thread.h22
1 files changed, 16 insertions, 6 deletions
diff --git a/thread.h b/thread.h
index fe8535b7..790c29a8 100644
--- a/thread.h
+++ b/thread.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: thread.h 4.3 2017/06/03 12:43:22 kls Exp $
+ * $Id: thread.h 4.4 2018/03/04 11:27:55 kls Exp $
*/
#ifndef __THREAD_H
@@ -171,11 +171,13 @@ class cStateKey;
class cStateLock {
friend class cStateKey;
private:
+ enum { emDisabled = 0, emArmed, emEnabled };
const char *name;
tThreadId threadId;
cRwLock rwLock;
int state;
- bool explicitModify;
+ int explicitModify;
+ cStateKey *syncStateKey;
void Unlock(cStateKey &StateKey, bool IncState = true);
///< Releases a lock that has been obtained by a previous call to Lock()
///< with the given StateKey. If this was a write-lock, and IncState is true,
@@ -211,13 +213,21 @@ public:
///< If Write is true (i.e. a write-lock is requested), the states of the
///< lock and the given StateKey don't matter, it will always try to obtain
///< a write lock.
- void SetExplicitModify(void) { explicitModify = true; }
+ void SetSyncStateKey(cStateKey &StateKey);
+ ///< Sets the given StateKey to be synchronized to the state of this lock.
+ ///< The caller must currenty hold a write lock on this lock, with a cStateKey
+ ///< that is different from the given StateKey. If, when removing the key that
+ ///< is holding the write lock, the StateKey's current state is the same as that
+ ///< of the lock, it will be increased together with the lock's state.
+ void SetExplicitModify(void);
///< If you have obtained a write lock on this lock, and you don't want its
///< state to be automatically incremented when the lock is released, a call to
- ///< this function will disable this, and you can explicitly call IncState()
+ ///< this function will disable this, and you can explicitly call SetModified()
///< to increment the state.
- void IncState(void);
- ///< Increments the state of this lock.
+ void SetModified(void);
+ ///< Sets this lock to have its state incremented when the current write lock
+ ///< state key is removed. Must have called SetExplicitModify() before calling
+ ///< this function.
};
class cStateKey {