Wikibase
MediaWiki Wikibase extension
Wikibase\Repo\PidLock Class Reference

Utility class for process identifier (PID) locking. More...

Public Member Functions

 __construct ( $module, $wikiId)
 
 getLock ( $force=false)
 Tries to allocate a process identifier based lock for the process, to avoid running more than one instance. More...
 
 removeLock ()
 Remove the process identifier lock. More...
 

Private Member Functions

 isAlive ( $pid)
 Check the given process identifier to see if it is alive. More...
 
 getStateFile ()
 Generate a name and path for a file to store some kind of state in. More...
 

Private Attributes

 $module
 
 $wikiId
 

Detailed Description

Utility class for process identifier (PID) locking.

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\PidLock::__construct (   $module,
  $wikiId 
)
Parameters
string$moduleused as a basis for the file name.
string$wikiIdthe wiki's id, used for per-wiki file names.

Member Function Documentation

◆ getLock()

Wikibase\Repo\PidLock::getLock (   $force = false)

Tries to allocate a process identifier based lock for the process, to avoid running more than one instance.

Note that this method creates the file if necessary.

Parameters
bool$forcemake the function skip the test and always grab the lock
Returns
bool true if we got the lock, i.e. if no instance is already running, or $force was set.

◆ getStateFile()

Wikibase\Repo\PidLock::getStateFile ( )
private

Generate a name and path for a file to store some kind of state in.

Returns
string File path

◆ isAlive()

Wikibase\Repo\PidLock::isAlive (   $pid)
private

Check the given process identifier to see if it is alive.

Parameters
int$pidthe process identifier to check
Returns
bool true if the process exist

◆ removeLock()

Wikibase\Repo\PidLock::removeLock ( )

Remove the process identifier lock.

Assumes that we hold it.

Returns
bool Success

Member Data Documentation

◆ $module

Wikibase\Repo\PidLock::$module
private

◆ $wikiId

Wikibase\Repo\PidLock::$wikiId
private

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