2017-07-15 16:44:06 -04:00
|
|
|
<?php
|
2017-11-16 20:23:18 -05:00
|
|
|
/** @license MIT
|
|
|
|
* Copyright 2017 J. King, Dustin Wilson et al.
|
|
|
|
* See LICENSE and AUTHORS files for details */
|
|
|
|
|
2017-07-15 16:44:06 -04:00
|
|
|
declare(strict_types=1);
|
2019-01-20 22:40:49 -05:00
|
|
|
namespace JKingWeb\Arsse\Service\Serial;
|
2017-08-29 10:50:31 -04:00
|
|
|
|
2017-07-17 07:47:57 -04:00
|
|
|
use JKingWeb\Arsse\Arsse;
|
2017-07-15 16:44:06 -04:00
|
|
|
|
|
|
|
class Driver implements \JKingWeb\Arsse\Service\Driver {
|
|
|
|
protected $queue = [];
|
2018-10-26 14:58:04 -04:00
|
|
|
|
2017-08-29 10:50:31 -04:00
|
|
|
public static function driverName(): string {
|
2019-01-20 22:40:49 -05:00
|
|
|
return Arsse::$lang->msg("Driver.Service.Serial.Name");
|
2017-07-15 16:44:06 -04:00
|
|
|
}
|
|
|
|
|
2017-08-29 10:50:31 -04:00
|
|
|
public static function requirementsMet(): bool {
|
2017-07-15 16:44:06 -04:00
|
|
|
// this driver has no requirements
|
|
|
|
return true;
|
|
|
|
}
|
2018-10-26 14:58:04 -04:00
|
|
|
|
2017-08-29 10:50:31 -04:00
|
|
|
public function __construct() {
|
2017-07-15 16:44:06 -04:00
|
|
|
}
|
|
|
|
|
2017-08-29 10:50:31 -04:00
|
|
|
public function queue(int ...$feeds): int {
|
2017-07-15 16:44:06 -04:00
|
|
|
$this->queue = array_merge($this->queue, $feeds);
|
|
|
|
return sizeof($this->queue);
|
|
|
|
}
|
|
|
|
|
2017-08-29 10:50:31 -04:00
|
|
|
public function exec(): int {
|
|
|
|
while (sizeof($this->queue)) {
|
2017-07-15 16:44:06 -04:00
|
|
|
$id = array_shift($this->queue);
|
2017-07-17 07:47:57 -04:00
|
|
|
Arsse::$db->feedUpdate($id);
|
2017-07-15 16:44:06 -04:00
|
|
|
}
|
2017-07-17 07:47:57 -04:00
|
|
|
return Arsse::$conf->serviceQueueWidth - sizeof($this->queue);
|
2017-07-15 16:44:06 -04:00
|
|
|
}
|
|
|
|
|
2019-10-19 18:51:01 -04:00
|
|
|
public function clean(): int {
|
|
|
|
$out = sizeof($this->queue);
|
2017-07-15 16:44:06 -04:00
|
|
|
$this->queue = [];
|
2019-10-19 18:51:01 -04:00
|
|
|
return $out;
|
2017-07-15 16:44:06 -04:00
|
|
|
}
|
2017-08-29 10:50:31 -04:00
|
|
|
}
|