43 $this->poolCounter = $poolCounter ??
44 MediaWikiServices::getInstance()->getPoolCounterFactory()->create( $type, $key );
80 public function error( $status ) {
90 return $this->poolCounter->isFastStaleEnabled();
100 $key = $this->poolCounter->getKey();
102 wfDebugLog(
'poolcounter',
"Pool key '$key' ({$this->type}): "
103 . $status->getMessage()->inLanguage(
'en' )->useDatabase(
false )->text() );
133 public function execute( $skipcache =
false ) {
134 if ( !$this->cacheable || $skipcache ) {
135 $status = $this->poolCounter->acquireForMe();
139 $status = $this->poolCounter->acquireForAnyone( 0 );
142 $staleResult = $this->
fallback(
true );
143 if ( $staleResult !==
false ) {
147 $status = $this->poolCounter->acquireForAnyone();
150 $status = $this->poolCounter->acquireForAnyone();
154 if ( !$status->isOK() ) {
160 switch ( $status->value ) {
169 $this->poolCounter->release();
174 if ( $result ===
false ) {
186 if ( $result !==
false ) {
198 $status = Status::newFatal( $errors[$status->value] ??
'pool-errorunknown' );
200 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.