phpDocumentor GalleryCore
Classes
[ class tree: GalleryCore ] [ index: GalleryCore ] [ all elements ]

Class: GalleryLockSystem

Source Location: /modules/core/classes/GalleryLockSystem.class

Class GalleryLockSystem

Class Overview

This is an interface for all locking systems. You must extend it and implement all of its methods in order to introduce a new locking system.

Located in /modules/core/classes/GalleryLockSystem.class [line 40]



		
				Author(s):
		
API Tags:
Abstract:  

Properties

Methods

[ Top ]
Direct descendents
Child Class Description
MockLockSystem This is a mock LockSystem to get rid of the pain of Flock platform calls in unit tests
FlockLockSystem Flock() based locking. This is fairly efficient, but it will not work on NFS and is known to be unreliable on some operating systems including some flavors of the 2.4 Linux kernel.
DatabaseLockSystem Database backed locking. This is less efficient than filesystem based locking, but is more reliable and portable.

[ Top ]
Property Summary
array   $_locks   Information about all the locks we currently hold.
array   $_releaseQueue   List of locks that are pending release.

[ Top ]
Method Summary
GalleryLockSystem   GalleryLockSystem()  
array   acquireReadLock()   Read lock one or more objects
array   acquireWriteLock()   Write lock one or more objects
array   getLockIds()   Return the ids of all the locks we hold
boolean   isReadLocked()   Return true if the given id is read locked or write locked
boolean   isWriteLocked()   Return true if the given id is write locked
GalleryStatus   refreshLocks()   Refresh all the locks that we hold so that they aren't accidentally considered expired
GalleryStatus   releaseAllLocks()   Release any locks that we're holding
GalleryStatus   releaseLocks()   Release the given lock(s) (queue the specified locks for later release on transactional databases or release them immediately if transactions are not supported)
GalleryStatus   releaseQueue()   Cleanup any locks queued for release
array   _acquireLock()   Extending class must implement this function to actually acquire a lock.
GalleryStatus   _moveObjectsBetweenLocks()   Move ids from givens locks into a new lock.
array   _newLockId()   Generate an id for a new lock.
GalleryStatus   _releaseLocksNow()   Release the given locks now
GalleryStatus   _removeObjectsFromLock()   Remove some object ids from the given lock.

[ Top ]
Properties
array   $_locks [line 49]

Information about all the locks we currently hold.

array of (lockId => array('lockId' => lock id, 'type' => LOCK_READ or LOCK_WRITE, 'ids' => array of locked object id => additional data))

API Tags:
Access:  protected


[ Top ]
array   $_releaseQueue [line 58]

List of locks that are pending release.

array of (lockId => array('lockId' => lock id, 'type' => LOCK_READ or LOCK_WRITE, 'ids' => array of locked object id => additional data))

API Tags:
Access:  protected


[ Top ]
Methods
Constructor GalleryLockSystem  [line 61]

  GalleryLockSystem GalleryLockSystem( )



[ Top ]
acquireReadLock  [line 73]

  array acquireReadLock( mixed $ids, [int $timeout = 10]  )

Read lock one or more objects

Parameters:
mixed   $ids:  array of ids to lock, or single int id
int   $timeout:  (optional) how many seconds to wait for the lock before giving up

API Tags:
Return:  GalleryStatus a status code mixed the lock id


Redefined in descendants as:

[ Top ]
acquireWriteLock  [line 119]

  array acquireWriteLock( mixed $ids, [int $timeout = 10]  )

Write lock one or more objects

Parameters:
mixed   $ids:  array of ids to lock, or single int id
int   $timeout:  (optional) how many seconds to wait for the lock before giving up

API Tags:
Return:  GalleryStatus a status code mixed the lock id


Redefined in descendants as:

[ Top ]
getLockIds  [line 367]

  array getLockIds( )

Return the ids of all the locks we hold


API Tags:
Return:  lock ids


Redefined in descendants as:

[ Top ]
isReadLocked  [line 197]

  boolean isReadLocked( int $id  )

Return true if the given id is read locked or write locked

Parameters:
int   $id:  an object id

API Tags:
Return:  true if the object is read locked


Redefined in descendants as:

[ Top ]
isWriteLocked  [line 213]

  boolean isWriteLocked( int $id  )

Return true if the given id is write locked

Parameters:
int   $id:  an object id

API Tags:
Return:  true if the object is write locked


Redefined in descendants as:

[ Top ]
refreshLocks  [line 358]

  GalleryStatus refreshLocks( int $freshUntil  )

Refresh all the locks that we hold so that they aren't accidentally considered expired

Parameters:
int   $freshUntil:  the new "fresh until" timestamp

API Tags:
Return:  a status code
Abstract:  


Redefined in descendants as:

[ Top ]
releaseAllLocks  [line 342]

  GalleryStatus releaseAllLocks( )

Release any locks that we're holding


API Tags:
Return:  a status code


Redefined in descendants as:

[ Top ]
releaseLocks  [line 231]

  GalleryStatus releaseLocks( mixed $lockIds  )

Release the given lock(s) (queue the specified locks for later release on transactional databases or release them immediately if transactions are not supported)

Parameters:
mixed   $lockIds:  array of lock ids, or a single lock id

API Tags:
Return:  a status code


Redefined in descendants as:

[ Top ]
releaseQueue  [line 266]

  GalleryStatus releaseQueue( )

Cleanup any locks queued for release


API Tags:
Return:  a status code


[ Top ]
_acquireLock  [line 187]

  array _acquireLock( array $ids, int $timeout, int $lockType  )

Extending class must implement this function to actually acquire a lock.

Parameters:
array   $ids:  of object ids
int   $timeout:  how many seconds to wait for the lock before giving up
int   $lockType:  LOCK_READ or LOCK_WRITE

API Tags:
Return:  GalleryStatus a status code int the lock id
Abstract:  
Access:  protected


Redefined in descendants as:

[ Top ]
_moveObjectsBetweenLocks  [line 311]

  GalleryStatus _moveObjectsBetweenLocks( array $relock, int $newLockId  )

Move ids from givens locks into a new lock.

Remove any locks that now have no objects remaining.

Parameters:
array   $relock:  of (lockId => array of ids)
int   $newLockId:  move ids into this lock

API Tags:
Return:  a status code
Access:  protected


Redefined in descendants as:

[ Top ]
_newLockId  [line 333]

  array _newLockId( )

Generate an id for a new lock.


API Tags:
Return:  GalleryStatus a status code mixed lockId
Abstract:  
Access:  protected


Redefined in descendants as:

[ Top ]
_releaseLocksNow  [line 285]

  GalleryStatus _releaseLocksNow( array $locks  )

Release the given locks now

Parameters:
array   $locks:  of lockId => lock

API Tags:
Return:  a status code
Abstract:  
Access:  protected


Redefined in descendants as:

[ Top ]
_removeObjectsFromLock  [line 298]

  GalleryStatus _removeObjectsFromLock( &$lock, array $ids, array $lock  )

Remove some object ids from the given lock.

Parameters:
array   $lock: 
array   $ids:  ids to remove
   &$lock: 

API Tags:
Return:  a status code
Abstract:  
Access:  protected


Redefined in descendants as:

[ Top ]

Documentation generated on Fri, 08 Oct 2010 05:00:42 -0700 by phpDocumentor 1.3.0RC6