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

Captures and maintains scheduling order for locks with a common name. More...

#include "mem_lock_state.h"

Classes

struct  Comparator
 
struct  StealComparator
 

Public Types

typedef std::set< MemLock
*, MemLockState::Comparator
WakeupOrderedLockSet
 
typedef std::set< MemLock
*, MemLockState::StealComparator
StealOrderedLockSet
 

Public Member Functions

const GoogleStringname () const
 
MemLockCreateLock (int64 sequence)
 
void RemoveLock (MemLock *lock)
 Called when lock is deleted. More...
 
void UnscheduleLock (MemLock *lock)
 
void ScheduleLock (MemLock *lock)
 
bool GrabLock (MemLock *lock)
 
void Unlock ()
 
void StealLock (MemLock *lock)
 
MemLockManagermanager ()
 
bool IsHeldInOrderedSet (MemLock *lock) const
 

Static Public Member Functions

template<typename T >
static int Compare (const T &a, const T &b)
 

Friends

class MemLockManager
 

Detailed Description

Captures and maintains scheduling order for locks with a common name.

Member Function Documentation

MemLock* net_instaweb::MemLockState::CreateLock ( int64  sequence)

Creates a new lock for this name, and track it. Note that NamedLocks are deleted independently even though they are created from the NamedLockManager. The MemLockState can outlive the MemLockManager, but will stay alive as long as any of its MemLocks are alive.

bool net_instaweb::MemLockState::GrabLock ( MemLock lock)

Attempts to take a lock immediately, returning false if that failed, in which case the caller is expected to set up its timing constraints and schedule it. Note that this doesn't call any callbacks; the caller is responsible for doing that.

bool net_instaweb::MemLockState::IsHeldInOrderedSet ( MemLock lock) const

Method to determine whether this lock is in any sets. This is used for debug-assertions to ensure we don't mutate lock state used for ordering the maps while the lock is in one.

void net_instaweb::MemLockState::RemoveLock ( MemLock lock)

Called when lock is deleted.

Called by MemLock::~MemLock to let us know it doesn't exist anymore. When the last lock is removed, the MemLockState is deleted.

void net_instaweb::MemLockState::ScheduleLock ( MemLock lock)

Adds a lock to the schedule maps. This happens when a lock is requested. Note that this can directly call lock Run/Cancel if they are due.

void net_instaweb::MemLockState::StealLock ( MemLock lock)

Steals the current lock by unlocking it, thus handing it to the next in queue, which must be lock. lock's Run function is called as well, in response to unlocking the current lock.

void net_instaweb::MemLockState::Unlock ( )

Releases the current lock, wakes up the next pending lock (if any) and calls its Run function.

void net_instaweb::MemLockState::UnscheduleLock ( MemLock lock)

Removes a lock from the current schedule. This is done when lock is granted or denied.

Friends And Related Function Documentation

friend class MemLockManager
friend

To allow the manager to construct


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