[JobQueue] Reduced deadlocks in claim() function.
[lhc/web/wiklou.git] / includes / job / JobQueue.php
index 6409cff..2778829 100644 (file)
@@ -31,6 +31,7 @@
 abstract class JobQueue {
        protected $wiki; // string; wiki ID
        protected $type; // string; job type
+       protected $order; // string; job priority for pop()
 
        const QoS_Atomic = 1; // integer; "all-or-nothing" job insertions
 
@@ -38,16 +39,23 @@ abstract class JobQueue {
         * @param $params array
         */
        protected function __construct( array $params ) {
-               $this->wiki = $params['wiki'];
-               $this->type = $params['type'];
+               $this->wiki  = $params['wiki'];
+               $this->type  = $params['type'];
+               $this->order = isset( $params['order'] ) ? $params['order'] : 'random';
        }
 
        /**
         * Get a job queue object of the specified type.
         * $params includes:
-        *     class : what job class to use (determines job type)
+        *     class : What job class to use (determines job type)
         *     wiki  : wiki ID of the wiki the jobs are for (defaults to current wiki)
         *     type  : The name of the job types this queue handles
+        *     order : Order that pop() selects jobs, either "timestamp" or "random".
+        *             If "timestamp" is used, the queue will effectively be FIFO. Note that
+        *             pop() will not be exactly FIFO, and even if it was, job completion would
+        *             not appear to be exactly FIFO since jobs can take different times to finish.
+        *             If "random" is used, pop() will pick jobs in random order. This might be
+        *             useful for improving concurrency depending on the queue storage medium.
         *
         * @param $params array
         * @return JobQueue