Page Speed Optimization Libraries
1.13.35.1
|
#include "file_system_lock_manager.h"
Public Member Functions | |
FileSystemLockManager (FileSystem *file_system, const StringPiece &base_path, Scheduler *scheduler, MessageHandler *handler) | |
virtual SchedulerBasedAbstractLock * | CreateNamedLock (const StringPiece &name) |
FileSystem * | file_system () const |
Simple accessors for constructor arguments. | |
Scheduler * | scheduler () const |
MessageHandler * | handler () const |
Use the locking routines in FileSystem to implement named locks. Requires a Scheduler as well because the FileSystem locks are non-blocking and we must deal with blocking until they are available. A MessageHandler is used to report file system errors during lock creation and cleanup.
net_instaweb::FileSystemLockManager::FileSystemLockManager | ( | FileSystem * | file_system, |
const StringPiece & | base_path, | ||
Scheduler * | scheduler, | ||
MessageHandler * | handler | ||
) |
Note: a FileSystemLockManager must outlive any and all locks that it creates. It does not assume ownership of the passed-in constructor arguments. (Except it does copy in base_path). The caller is responsible for ensuring that base_path exists.
|
virtual |
Multiple lock objects with the same name will manage the same underlying lock. Lock names must be legal file names according to file_system.
A lock created by CreateNamedLock will be Unlocked when it is destructed if the NamedLock object appears to still be locked at destruction time. This attempts to ensure that the file system is not littered with the remnants of dead locks. A given NamedLock object should Lock and Unlock in matched pairs; DO NOT use separate NamedLock objects created with the same name to perform a Lock and the corresponding Unlock.
Implements net_instaweb::NamedLockManager.