/** * getQueue: Returns the semaphore message resource. * * @access public */ public static function getQueue() { # Some unique ID define('QUEUE_KEY', 12345); # Different type of actions define('QUEUE_TYPE_START', 1); define('QUEUE_TYPE_END', 2); # Setup the queue self::$queue = msg_get_queue(QUEUE_KEY); # Return the queue return self::$queue; }
public static function enqueue($task, $concurrence = false) { if ($concurrence) { if (self::$concurrenceQueue == null) { self::$concurrenceQueue = Yii::app()->concurrenceQueue; } return self::$concurrenceQueue->addTask($task) && self::$concurrenceQueue->push(); } else { if (self::$queue == null) { self::$queue = Yii::app()->queue; } return self::$queue->addTask($task) && self::$queue->push(); } }
public function submit($task) { $taskId = $this->queue->queue($task, true); return new QueuedTask($taskId, $this->queue); }