dbqueuemanager a little more sane about sleeping

This commit is contained in:
Evan Prodromou 2009-07-23 14:56:21 -07:00
parent f227006789
commit a3a5d23c54

View File

@ -22,7 +22,6 @@
* @category QueueManager * @category QueueManager
* @package Laconica * @package Laconica
* @author Evan Prodromou <evan@controlyourself.ca> * @author Evan Prodromou <evan@controlyourself.ca>
* @author Sarven Capadisli <csarven@controlyourself.ca>
* @copyright 2009 Control Yourself, Inc. * @copyright 2009 Control Yourself, Inc.
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
* @link http://laconi.ca/ * @link http://laconi.ca/
@ -86,10 +85,14 @@ class DBQueueManager extends QueueManager
$start = time(); $start = time();
$result = null; $result = null;
$sleeptime = 1;
do { do {
$qi = Queue_item::top($queue); $qi = Queue_item::top($queue);
if (empty($qi)) { if (empty($qi)) {
sleep(1); $this->_log(LOG_DEBUG, "No new queue items, sleeping $sleeptime seconds.");
sleep($sleeptime);
$sleeptime *= 2;
} else { } else {
$notice = Notice::staticGet('id', $qi->notice_id); $notice = Notice::staticGet('id', $qi->notice_id);
if (!empty($notice)) { if (!empty($notice)) {
@ -100,6 +103,7 @@ class DBQueueManager extends QueueManager
$qi->free(); $qi->free();
$qi = null; $qi = null;
} }
$sleeptime = 1;
} }
} while (empty($result) && (is_null($timeout) || (time() - $start) < $timeout)); } while (empty($result) && (is_null($timeout) || (time() - $start) < $timeout));