改名
This commit is contained in:
+56
-43
@@ -4,70 +4,83 @@
|
||||
namespace Server;
|
||||
|
||||
|
||||
use JetBrains\PhpStorm\Pure;
|
||||
use Swoole\Coroutine\Channel;
|
||||
|
||||
class ApplicationStore
|
||||
{
|
||||
|
||||
|
||||
private static ?ApplicationStore $applicationStore = null;
|
||||
private static ?ApplicationStore $applicationStore = null;
|
||||
|
||||
|
||||
private Channel $lock;
|
||||
private Channel $lock;
|
||||
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
$this->lock = new Channel(99999);
|
||||
}
|
||||
private function __construct()
|
||||
{
|
||||
$this->lock = new Channel(99999);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return \Server\ApplicationStore|null
|
||||
*/
|
||||
public static function getStore()
|
||||
{
|
||||
if (!(static::$applicationStore instanceof ApplicationStore)) {
|
||||
static::$applicationStore = new ApplicationStore();
|
||||
}
|
||||
return static::$applicationStore;
|
||||
}
|
||||
/**
|
||||
* @return ApplicationStore|null
|
||||
*/
|
||||
public static function getStore(): ?ApplicationStore
|
||||
{
|
||||
if (!(static::$applicationStore instanceof ApplicationStore)) {
|
||||
static::$applicationStore = new ApplicationStore();
|
||||
}
|
||||
return static::$applicationStore;
|
||||
}
|
||||
|
||||
|
||||
public function add()
|
||||
{
|
||||
$this->lock->push(1);
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function add(): static
|
||||
{
|
||||
$this->lock->push(1);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
public function waite()
|
||||
{
|
||||
$this->lock->pop(-1);
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function waite(): void
|
||||
{
|
||||
if ($this->lock->isEmpty()) {
|
||||
return;
|
||||
}
|
||||
$this->lock->pop(-1);
|
||||
}
|
||||
|
||||
|
||||
public function done()
|
||||
{
|
||||
$this->lock->pop();
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function done(): void
|
||||
{
|
||||
$this->lock->pop();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isBusy()
|
||||
{
|
||||
return !$this->lock->isEmpty();
|
||||
}
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isBusy(): bool
|
||||
{
|
||||
return !$this->lock->isEmpty();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus(): string
|
||||
{
|
||||
return env('state');
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
#[Pure] public function getStatus(): string
|
||||
{
|
||||
return env('state');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user