Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
net_instaweb::NamedLock Class Referenceabstract

Non-blocking locking class. More...

#include "named_lock_manager.h"

Inheritance diagram for net_instaweb::NamedLock:
net_instaweb::MemLock net_instaweb::SchedulerBasedAbstractLock

Public Member Functions

virtual ~NamedLock ()
 Destructors of extending classes must unlock the lock if held on destruct.
 
virtual void LockTimedWait (int64 wait_ms, Function *callback)=0
 
virtual void LockTimedWaitStealOld (int64 wait_ms, int64 steal_ms, Function *callback)=0
 
virtual void Unlock ()=0
 
virtual bool Held ()=0
 
virtual GoogleString name () const =0
 The name the lock was created with, for debugging/logging purposes.
 

Detailed Description

Non-blocking locking class.

Member Function Documentation

virtual bool net_instaweb::NamedLock::Held ( )
pure virtual

Returns true if this lock is held by this particular lock object.

Note: in some implementations Held() may remain true until Unlock regardless if another lock steals.

Implemented in net_instaweb::MemLock.

virtual void net_instaweb::NamedLock::LockTimedWait ( int64  wait_ms,
Function callback 
)
pure virtual

Attempts to take a lock. callback->Run() is called if the lock was granted, and callback->Cancel() is called if the lock could not be obtained within wait_ms. Note that the callback may be called directly from this method, or from another thread.

The caller is responsible for making sure that callback does not block.

Todo:
TODO(jmarantz): consider removing this method as it has no callers in production code, though it does have callers in tests.

Implemented in net_instaweb::SchedulerBasedAbstractLock, and net_instaweb::MemLock.

virtual void net_instaweb::NamedLock::LockTimedWaitStealOld ( int64  wait_ms,
int64  steal_ms,
Function callback 
)
pure virtual

Attempts to take a lock, calling callback->Run() when it is granted. If the current lock holder has locked it for more than steal_ms, the lock is "stolen". If the lock cannot be obtained within wait_ms from when this method was called, the lock is denied, and callback->Cancel() is called.

Note that the callback may be called directly from this method, or from another thread.

The caller is responsible for making sure that callback does not block.

Note that even if wait_ms > steal_ms, callback->Cancel() may be called if there are multiple concurrent attempts to take the lock.

Implemented in net_instaweb::SchedulerBasedAbstractLock, and net_instaweb::MemLock.

virtual void net_instaweb::NamedLock::Unlock ( )
pure virtual

Relinquish lock. Non-blocking, however note when this lock is relinquished another lock may be granted, resulting in its callback->Run() method being called from Unlock.

Implemented in net_instaweb::MemLock.


The documentation for this class was generated from the following file: