19 #ifndef PAGESPEED_KERNEL_BASE_NAMED_LOCK_TESTER_H_
20 #define PAGESPEED_KERNEL_BASE_NAMED_LOCK_TESTER_H_
22 #include "base/logging.h"
30 namespace net_instaweb {
49 &NamedLockTester::LockAcquired,
50 &NamedLockTester::LockFailed));
52 CHECK(WasCalled()) <<
"LockTimedWait returned lock operation completed";
55 bool LockTimedWaitStealOld(int64 wait_ms, int64 steal_ms,
NamedLock* lock) {
59 &NamedLockTester::LockAcquired,
60 &NamedLockTester::LockFailed));
63 <<
"LockTimedWaitStealOld returned lock operation completed";
66 bool LockTimedWait(int64 wait_ms,
NamedLock* lock) {
70 &NamedLockTester::LockAcquired,
71 &NamedLockTester::LockFailed));
73 CHECK(WasCalled()) <<
"LockTimedWait returned lock operation completed";
82 lock_for_deletion_.reset(old_lock);
83 CHECK(old_lock->
Held()) <<
"UnlockWithDelete old_lock must be held";
84 CHECK(!new_lock->
Held()) <<
"UnlockWithDelete new_lock must not be held";
90 &NamedLockTester::DeleteLock,
91 &NamedLockTester::LockFailed));
94 CHECK(WasCalled()) <<
"UnlockWithDelete lock operation did not complete";
102 lock_for_deletion_.reset(old_lock);
103 CHECK(old_lock->
Held()) <<
"StealWithDelete old_lock must be held";
104 CHECK(!new_lock->
Held()) <<
"StealWithDelete new_lock must not be held";
110 &NamedLockTester::DeleteLock,
111 &NamedLockTester::LockFailed));
113 CHECK(WasCalled()) <<
"StealWithDelete lock operation did not complete";
120 lock_for_deletion_.reset();
124 if (quiesce_.get() != NULL) {
135 quiesce_.reset(quiesce);
145 void LockAcquired() {
155 return acquired_ || failed_;
164 scoped_ptr<AbstractMutex> mutex_;
165 scoped_ptr<Function> quiesce_;
166 scoped_ptr<NamedLock> lock_for_deletion_;
Function * MakeFunction(C *object, void(C::*run)())
Makes a Function* that calls a 0-arg class method.
Definition: function.h:291
Definition: named_lock_tester.h:37
virtual void LockTimedWaitStealOld(int64 wait_ms, int64 steal_ms, Function *callback)=0
Non-blocking locking class.
Definition: named_lock_manager.h:31
bool StealWithDelete(int64 steal_ms, NamedLock *old_lock, NamedLock *new_lock)
As for UnlockWithDelete, but for a steal. Frees both locks.
Definition: named_lock_tester.h:99
void set_quiesce(Function *quiesce)
Definition: named_lock_tester.h:133
Definition: scoped_ptr.h:30
Definition: function.h:47
#define ScopedMutex(x)
Definition: abstract_mutex.h:69
Helper class for lexically scoped mutexing.
Definition: abstract_mutex.h:46
bool UnlockWithDelete(NamedLock *old_lock, NamedLock *new_lock)
Definition: named_lock_tester.h:80
void set_delete_after_callback(bool x)
Definition: function.h:80
Definition: thread_system.h:40
virtual void LockTimedWait(int64 wait_ms, Function *callback)=0
virtual CondvarCapableMutex * NewMutex()=0