summaryrefslogtreecommitdiff
path: root/ace/Synch.h
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2000-09-11 18:21:53 +0000
committerSteve Huston <shuston@riverace.com>2000-09-11 18:21:53 +0000
commit53c3012ea338a0298ce8870bb27453fa91d6aa87 (patch)
treefd645db7ebf5ba5552b55eb49349859ee637d82d /ace/Synch.h
parentd27eb2ae64f4dd6d0080558a738167da0cdfabd6 (diff)
downloadATCD-53c3012ea338a0298ce8870bb27453fa91d6aa87.tar.gz
ChangeLogTag:Mon Sep 11 12:57:31 2000 Steve Huston <shuston@riverace.com>
Diffstat (limited to 'ace/Synch.h')
-rw-r--r--ace/Synch.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/ace/Synch.h b/ace/Synch.h
index 889c257048c..57edfb55250 100644
--- a/ace/Synch.h
+++ b/ace/Synch.h
@@ -96,6 +96,11 @@ public:
// doesn't support read locks then this just calls <acquire>.
// Returns -1 on failure. If we "failed" because someone else
// already had the lock, <errno> is set to <EBUSY>.
+
+ virtual int tryacquire_write_upgrade (void) = 0;
+ // Conditionally try to upgrade a lock held for read to a write lock.
+ // If the locking mechanism doesn't support read locks then this just
+ // calls <acquire>. Returns 0 on success, -1 on failure.
};
class ACE_Export ACE_Adaptive_Lock : public ACE_Lock
@@ -125,6 +130,7 @@ public:
virtual int acquire_write (void);
virtual int tryacquire_read (void);
virtual int tryacquire_write (void);
+ virtual int tryacquire_write_upgrade (void);
void dump (void) const;
protected:
@@ -191,6 +197,13 @@ public:
// -1 on failure. If we "failed" because someone else already had
// the lock, <errno> is set to <EBUSY>.
+ int tryacquire_write_upgrade (short whence = 0,
+ off_t start = 0,
+ off_t len = 1);
+ // Conditionally upgrade to a write lock (i.e., won't block). Returns
+ // -1 on failure. If we "failed" because someone else already had
+ // the lock, <errno> is set to <EBUSY>.
+
int acquire_read (short whence = 0, off_t start = 0, off_t len = 1);
// Acquire a read lock, but block if a writer hold the lock.
// Returns -1 on failure. If we "failed" because someone else
@@ -311,6 +324,12 @@ public:
// Returns -1 on failure. If we "failed" because someone else
// already had the lock, <errno> is set to <EBUSY>.
+ int tryacquire_write_upgrade (void);
+ // This is only here to make the <ACE_Semaphore>
+ // interface consistent with the other synchronization APIs.
+ // Assumes the caller has already acquired the semaphore using one of
+ // the above calls, and returns 0 (success) always.
+
void dump (void) const;
// Dump the state of an object.
@@ -396,6 +415,12 @@ public:
// Returns -1 on failure. If we "failed" because someone else
// already had the lock, <errno> is set to <EBUSY>.
+ int tryacquire_write_upgrade (void);
+ // This is only here to make the <ACE_Process_Semaphore>
+ // interface consistent with the other synchronization APIs.
+ // Assumes the caller has already acquired the semaphore using one of
+ // the above calls, and returns 0 (success) always.
+
#if defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM) || defined (ACE_PSOS)
const ACE_sema_t &lock (void) const;
// Return the underlying lock.
@@ -437,6 +462,7 @@ public:
int release (size_t);
int acquire_write (void);
int tryacquire_write (void);
+ int tryacquire_write_upgrade (void);
int acquire_read (void);
int tryacquire_read (void);
@@ -484,6 +510,14 @@ public:
int tryacquire_write (void);
// Conditionally acquire a write lock (i.e., won't block).
+ int tryacquire_write_upgrade (void);
+ // Conditionally upgrade a read lock to a write lock. This only
+ // works if there are no other readers present, in which case the
+ // method returns 0. Otherwise, the method returns -1 and sets
+ // <errno> to <EBUSY>. Note that the caller of this method *must*
+ // already possess this lock as a read lock (but this condition is
+ // not checked by the current implementation).
+
int acquire (void);
// Note, for interface uniformity with other synchronization
// wrappers we include the <acquire> method. This is implemented as
@@ -578,6 +612,11 @@ public:
// failure. If we "failed" because someone else already had the
// lock, <errno> is set to <EBUSY>.
+ int tryacquire_write_upgrade (void);
+ // This is only here for consistency with the other synchronization
+ // APIs and usability with Lock adapters. Assumes the caller already has
+ // acquired the mutex and returns 0 in all cases.
+
const ACE_mutex_t &lock (void) const;
// Return the underlying mutex.
@@ -660,6 +699,11 @@ public:
// failure. If we "failed" because someone else already had the
// lock, <errno> is set to <EBUSY>.
+ int tryacquire_write_upgrade (void);
+ // This is only here for consistency with the other synchronization
+ // APIs and usability with Lock adapters. Assumes the caller already has
+ // acquired the mutex and returns 0 in all cases.
+
#if defined (ACE_WIN32) || defined (ACE_HAS_POSIX_SEM) || defined (ACE_PSOS)
const ACE_mutex_t &lock (void) const;
// Return the underlying mutex.
@@ -738,6 +782,10 @@ public:
// failure. If we "failed" because someone else already had the
// lock, <errno> is set to <EBUSY>.
+ int tryacquire_write_upgrade (void);
+ // Attempt to upgrade a read lock to a write lock. Returns 0 on
+ // success, -1 on failure.
+
const ACE_File_Lock &lock (void) const;
// Return the underlying lock.
@@ -796,6 +844,7 @@ public:
int release (void);
int acquire_write (void);
int tryacquire_write (void);
+ int tryacquire_write_upgrade (void);
int acquire_read (void);
int tryacquire_read (void);
@@ -1129,6 +1178,12 @@ public:
// Returns -1 on failure. If we "failed" because someone else
// already had the lock, <errno> is set to <EBUSY>.
+ int tryacquire_write_upgrade (void);
+ // This is only here to make the <ACE_Thread_Mutex>
+ // interface consistent with the other synchronization APIs.
+ // Assumes the caller has already acquired the mutex using one of
+ // the above calls, and returns 0 (success) always.
+
const ACE_thread_mutex_t &lock (void) const;
// Return the underlying mutex.
@@ -1381,6 +1436,12 @@ public:
// because someone else already had the lock, <errno> is set to
// <EBUSY>.
+ int tryacquire_write_upgrade (void);
+ // This is only here to make the <ACE_Recursive_Thread_Mutex>
+ // interface consistent with the other synchronization APIs.
+ // Assumes the caller has already acquired the mutex using one of
+ // the above calls, and returns 0 (success) always.
+
int release (void);
// Releases a recursive mutex (will not release mutex until all the
// nesting level drops to 0, which means the mutex is no longer