MediaWiki REL1_39
PoolCounterWork Class Reference

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

Inheritance diagram for PoolCounterWork:

Public Member Functions

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

Protected Member Functions

 isFastStaleEnabled ()
 Should fast stale mode be used?
 

Protected Attributes

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

Detailed Description

Class for dealing with PoolCounters using class members.

Definition at line 27 of file PoolCounterWork.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 40 of file PoolCounterWork.php.

References $type, and PoolCounter\factory().

Member Function Documentation

◆ doWork()

PoolCounterWork::doWork ( )
abstract

Actually perform the work, caching it if needed.

Returns
mixed|false Work result or false

Reimplemented in PoolCounterWorkViaCallback, PoolWorkArticleView, PoolWorkArticleViewCurrent, and PoolWorkArticleViewOld.

Referenced by execute().

◆ error()

PoolCounterWork::error ( $status)

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

Parameters
Status$status
Returns
mixed|false

Reimplemented in PoolCounterWorkViaCallback, and PoolWorkArticleView.

Definition at line 79 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 one of the following methods:

  • 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.

In slow stale mode, these three methods are called in the sequence given above, and the first non-false response is used.

In fast stale mode, fallback() is called first if the lock acquisition would block. If fallback() returns false, the lock is waited on, then the three methods are called in the same sequence as for slow stale mode, including potentially calling fallback() a second time.

Parameters
bool$skipcache
Returns
mixed

Definition at line 127 of file PoolCounterWork.php.

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

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

◆ fallback()

PoolCounterWork::fallback ( $fast)

A work not so good (eg.

expired one) but better than an error message.

Parameters
bool$fastTrue if PoolCounter is requesting a fast stale response (pre-wait)
Returns
mixed|false Work result or false

Reimplemented in PoolCounterWorkViaCallback, and PoolWorkArticleViewCurrent.

Definition at line 69 of file PoolCounterWork.php.

Referenced by execute().

◆ getCachedWork()

PoolCounterWork::getCachedWork ( )

Retrieve the work from cache.

Returns
mixed|false Work result or false

Reimplemented in PoolCounterWorkViaCallback, PoolWorkArticleViewCurrent, and PoolWorkArticleViewOld.

Definition at line 58 of file PoolCounterWork.php.

Referenced by execute().

◆ isFastStaleEnabled()

PoolCounterWork::isFastStaleEnabled ( )
protected

Should fast stale mode be used?

Returns
bool

Definition at line 88 of file PoolCounterWork.php.

Referenced by execute().

◆ logError()

PoolCounterWork::logError ( $status)

Log an error.

Parameters
Status$status
Returns
void

Definition at line 98 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.

Referenced by PoolWorkArticleViewCurrent\__construct().

◆ $type

string PoolCounterWork::$type = 'generic'
protected

Definition at line 29 of file PoolCounterWork.php.

Referenced by PoolCounterWorkViaCallback\__construct().


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