MediaWiki  1.23.2
PoolCounter.php
Go to the documentation of this file.
1 <?php
42 abstract class PoolCounter {
43  /* Return codes */
44  const LOCKED = 1; /* Lock acquired */
45  const RELEASED = 2; /* Lock released */
46  const DONE = 3; /* Another worker did the work for you */
47 
48  const ERROR = -1; /* Indeterminate error */
49  const NOT_LOCKED = -2; /* Called release() with no lock held */
50  const QUEUE_FULL = -3; /* There are already maxqueue workers on this lock */
51  const TIMEOUT = -4; /* Timeout exceeded */
52  const LOCK_HELD = -5; /* Cannot acquire another lock while you have one lock held */
53 
55  protected $key;
57  protected $workers;
59  protected $maxqueue;
61  protected $timeout;
62 
68  protected function __construct( $conf, $type, $key ) {
69  $this->key = $key;
70  $this->workers = $conf['workers'];
71  $this->maxqueue = $conf['maxqueue'];
72  $this->timeout = $conf['timeout'];
73  }
74 
83  public static function factory( $type, $key ) {
84  global $wgPoolCounterConf;
85  if ( !isset( $wgPoolCounterConf[$type] ) ) {
86  return new PoolCounter_Stub;
87  }
88  $conf = $wgPoolCounterConf[$type];
89  $class = $conf['class'];
90 
91  return new $class( $conf, $type, $key );
92  }
93 
97  public function getKey() {
98  return $this->key;
99  }
100 
106  abstract public function acquireForMe();
107 
114  abstract public function acquireForAnyone();
115 
123  abstract public function release();
124 }
125 
126 class PoolCounter_Stub extends PoolCounter {
127  public function __construct() {
128  /* No parameters needed */
129  }
130 
131  public function acquireForMe() {
133  }
134 
135  public function acquireForAnyone() {
137  }
138 
139  public function release() {
141  }
142 }
PoolCounter_Stub\release
release()
I have successfully finished my task.
Definition: PoolCounter.php:136
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
PoolCounter\LOCK_HELD
const LOCK_HELD
Definition: PoolCounter.php:52
PoolCounter_Stub\acquireForAnyone
acquireForAnyone()
I want to do this task, but if anyone else does it instead, it's also fine for me.
Definition: PoolCounter.php:132
PoolCounter\NOT_LOCKED
const NOT_LOCKED
Definition: PoolCounter.php:49
PoolCounter\acquireForMe
acquireForMe()
I want to do this task and I need to do it myself.
Status\newGood
static newGood( $value=null)
Factory function for good results.
Definition: Status.php:77
PoolCounter\LOCKED
const LOCKED
Definition: PoolCounter.php:44
PoolCounter\release
release()
I have successfully finished my task.
PoolCounter\$workers
integer $workers
Maximum number of workers doing the task simultaneously *.
Definition: PoolCounter.php:55
PoolCounter\acquireForAnyone
acquireForAnyone()
I want to do this task, but if anyone else does it instead, it's also fine for me.
PoolCounter
When you have many workers (threads/servers) giving service, and a cached item expensive to produce e...
Definition: PoolCounter.php:42
key
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling but I prefer the flexibility This should also do the output encoding The system allocates a global one in $wgOut Title Represents the title of an and does all the work of translating among various forms such as plain database key
Definition: design.txt:25
PoolCounter\__construct
__construct( $conf, $type, $key)
Definition: PoolCounter.php:65
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
PoolCounter\$key
string $key
All workers with the same key share the lock *.
Definition: PoolCounter.php:54
PoolCounter\QUEUE_FULL
const QUEUE_FULL
Definition: PoolCounter.php:50
PoolCounter\ERROR
const ERROR
Definition: PoolCounter.php:48
PoolCounter\factory
static factory( $type, $key)
Create a Pool counter.
Definition: PoolCounter.php:80
PoolCounter\getKey
getKey()
Definition: PoolCounter.php:94
PoolCounter\$maxqueue
$maxqueue
Definition: PoolCounter.php:57
PoolCounter_Stub
Definition: PoolCounter.php:123
PoolCounter\$timeout
float $timeout
Maximum time in seconds to wait for the lock *.
Definition: PoolCounter.php:58
PoolCounter_Stub\acquireForMe
acquireForMe()
I want to do this task and I need to do it myself.
Definition: PoolCounter.php:128
PoolCounter\RELEASED
const RELEASED
Definition: PoolCounter.php:45
PoolCounter\TIMEOUT
const TIMEOUT
Definition: PoolCounter.php:51
PoolCounter\DONE
const DONE
Definition: PoolCounter.php:46
PoolCounter_Stub\__construct
__construct()
Definition: PoolCounter.php:124
$type
$type
Definition: testCompression.php:46