MediaWiki  master
PoolCounterWork Class Reference

Class for dealing with PoolCounters using class members. More...

Inheritance diagram for PoolCounterWork:
Collaboration diagram for PoolCounterWork:

Public Member Functions

 __construct ( $type, $key)
 
 doWork ()
 Actually perform the work, caching it if needed. More...
 
 error ( $status)
 Do something with the error, like showing it to the user. More...
 
 execute ( $skipcache=false)
 Get the result of the work (whatever it is), or the result of the error() function. More...
 
 fallback ()
 A work not so good (eg. More...
 
 getCachedWork ()
 Retrieve the work from cache. More...
 
 logError ( $status)
 Log an error. More...
 

Protected Attributes

bool $cacheable = false
 
string $type = 'generic'
 

Private Attributes

PoolCounter $poolCounter
 

Detailed Description

Class for dealing with PoolCounters using class members.

Definition at line 27 of file PoolCounterWork.php.

Constructor & Destructor Documentation

◆ __construct()

PoolCounterWork::__construct (   $type,
  $key 
)
Parameters
string$typeThe class of actions to limit concurrency for (task type)
string$keyKey that identifies the queue this work is placed on

Definition at line 39 of file PoolCounterWork.php.

References $type, doWork(), and PoolCounter\factory().

Member Function Documentation

◆ doWork()

PoolCounterWork::doWork ( )
abstract

Actually perform the work, caching it if needed.

Returns
mixed Work result or false

Referenced by __construct(), and execute().

◆ error()

PoolCounterWork::error (   $status)

Do something with the error, like showing it to the user.

Parameters
Status$status
Returns
bool

Definition at line 74 of file PoolCounterWork.php.

Referenced by execute().

◆ execute()

PoolCounterWork::execute (   $skipcache = false)

Get the result of the work (whatever it is), or the result of the error() function.

This returns the result of the first applicable method that returns a non-false value, where the methods are checked in the following order:

  • a) doWork() : Applies if the work is exclusive or no another process is doing it, and on the condition that either this process successfully entered the pool or the pool counter is down.
  • b) doCachedWork() : Applies if the work is cacheable and this blocked on another process which finished the work.
  • c) fallback() : Applies for all remaining cases. If these all fall through (by returning false), then the result of error() is returned.
Parameters
bool$skipcache
Returns
mixed

Definition at line 106 of file PoolCounterWork.php.

References PoolCounter\DONE, doWork(), PoolCounter\ERROR, error(), fallback(), getCachedWork(), PoolCounter\LOCK_HELD, PoolCounter\LOCKED, logError(), StatusValue\newFatal(), PoolCounter\QUEUE_FULL, and PoolCounter\TIMEOUT.

Referenced by DjVuHandler\doTransform(), File\getThumbnailSource(), and wfGenerateThumbnail().

◆ fallback()

PoolCounterWork::fallback ( )

A work not so good (eg.

expired one) but better than an error message.

Returns
mixed Work result or false

Definition at line 63 of file PoolCounterWork.php.

Referenced by execute().

◆ getCachedWork()

PoolCounterWork::getCachedWork ( )

Retrieve the work from cache.

Returns
mixed Work result or false

Definition at line 54 of file PoolCounterWork.php.

Referenced by execute().

◆ logError()

PoolCounterWork::logError (   $status)

Log an error.

Parameters
Status$status
Returns
void

Definition at line 84 of file PoolCounterWork.php.

References wfDebugLog().

Referenced by execute().

Member Data Documentation

◆ $cacheable

bool PoolCounterWork::$cacheable = false
protected

Definition at line 31 of file PoolCounterWork.php.

◆ $poolCounter

PoolCounter PoolCounterWork::$poolCounter
private

Definition at line 33 of file PoolCounterWork.php.

◆ $type

string PoolCounterWork::$type = 'generic'
protected

Definition at line 29 of file PoolCounterWork.php.

Referenced by __construct(), and PoolCounterWorkViaCallback\__construct().


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