42 $this->poolCounter = $poolCounter ??
43 MediaWikiServices::getInstance()->getPoolCounterFactory()->create(
$type, $key );
79 public function error( $status ) {
89 return $this->poolCounter->isFastStaleEnabled();
99 $key = $this->poolCounter->getKey();
101 wfDebugLog(
'poolcounter',
"Pool key '$key' ({$this->type}): "
102 . $status->getMessage()->inLanguage(
'en' )->useDatabase(
false )->text() );
132 public function execute( $skipcache =
false ) {
133 if ( !$this->cacheable || $skipcache ) {
134 $status = $this->poolCounter->acquireForMe();
138 $status = $this->poolCounter->acquireForAnyone( 0 );
141 $staleResult = $this->
fallback(
true );
142 if ( $staleResult !==
false ) {
146 $status = $this->poolCounter->acquireForAnyone();
149 $status = $this->poolCounter->acquireForAnyone();
153 if ( !$status->isOK() ) {
159 switch ( $status->value ) {
168 $this->poolCounter->release();
173 if ( $result ===
false ) {
185 if ( $result !==
false ) {
197 $status =
Status::newFatal( $errors[$status->value] ??
'pool-errorunknown' );
199 return $this->
error( $status );
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
Class for dealing with PoolCounters using class members.
error( $status)
Do something with the error, like showing it to the user.
getCachedWork()
Retrieve the work from cache.
fallback( $fast)
A work not so good (eg.
execute( $skipcache=false)
Get the result of the work (whatever it is), or the result of the error() function.
isFastStaleEnabled()
Should fast stale mode be used?
doWork()
Actually perform the work, caching it if needed.
__construct(string $type, string $key, PoolCounter $poolCounter=null)
logError( $status)
Log an error.
Semaphore semantics to restrict how many workers may concurrently perform a task.
static newFatal( $message,... $parameters)
Factory function for fatal errors.