19 #ifndef PAGESPEED_KERNEL_BASE_MEM_LOCK_H_
20 #define PAGESPEED_KERNEL_BASE_MEM_LOCK_H_
26 namespace net_instaweb {
33 static const int64 kDoNotSteal = -1;
34 static const int64 kNotHeld = -1;
35 static const int64 kNotPending = -1;
42 virtual bool Held() {
return grant_time_ms_ != kNotHeld; }
71 int64 grant_time_ms()
const {
return grant_time_ms_; }
76 int64 steal_ms()
const {
return steal_ms_; }
80 void Grant(int64 grant_time_ms);
96 void CalculateWakeupTime(int64 held_lock_grant_time_ms);
99 bool CanSteal()
const {
return steal_ms_ != kDoNotSteal; }
102 bool IsPending()
const {
return wakeup_time_ms_ != kNotPending; }
110 bool ShouldCancelOnWakeup()
const {
111 return cancel_time_ms_ == wakeup_time_ms_;
114 MemLockState* lock_state_;
117 int64 cancel_time_ms_;
118 int64 grant_time_ms_;
124 int64 wakeup_time_ms_;
Non-blocking locking class.
Definition: named_lock_manager.h:31
int StableCompare(const MemLock *that) const
virtual bool Held()
Definition: mem_lock.h:42
virtual void LockTimedWait(int64 wait_ms, Function *callback)
Captures and maintains scheduling order for locks with a common name.
Definition: mem_lock_state.h:34
Definition: mem_lock.h:31
Definition: function.h:47
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
int64 wakeup_time_ms() const
Definition: mem_lock.h:52
virtual GoogleString name() const
The name the lock was created with, for debugging/logging purposes.
virtual void LockTimedWaitStealOld(int64 wait_ms, int64 steal_ms, Function *callback)