Skip to content

Commit

Permalink
Merge changes from 0.8-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
cclilshy committed Oct 25, 2024
1 parent 785ed13 commit 8523568
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 235 deletions.
2 changes: 1 addition & 1 deletion README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ visit [Quick Deployment](https://ripple.cloudtay.com/docs/install/server)
### Thanks

<a href="https://www.jetbrains.com/?from=ripple" target="__blank">
<img src="https://www.jetbrains.com/company/brand/img/jetbrains_logo.png" width="200">
<img src="https://www.jetbrains.com/company/brand/img/jetbrains_logo.png" width="200" alt="">
</a>

[Jetbrains](https://www.jetbrains.com/?from=ripple) Free development tools are provided for this project
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ composer require cloudtay/ripple-driver
### 特别致谢

<a href="https://www.jetbrains.com/?from=ripple" target="__blank">
<img src="https://www.jetbrains.com/company/brand/img/jetbrains_logo.png" width="200">
<img src="https://www.jetbrains.com/company/brand/img/jetbrains_logo.png" width="200" alt="">
</a>

[Jetbrains](https://www.jetbrains.com/?from=ripple) 为本项目提供了免费的开发工具
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
"phpunit/phpunit": "*",
"symfony/console": "*",
"topthink/framework": "*",
"workerman/workerman": "dev-master",
"workerman/workerman": "*",
"workerman/webman-framework": "dev-master",
"yiisoft/yii2": "^2.0@beta",
"cloudtay/ripple": "0.8.x-dev",
"cloudtay/ripple": "dev-main",
"cloudtay/ripple-http": "dev-main",
"cloudtay/ripple-websocket": "dev-main"
},
Expand Down
32 changes: 0 additions & 32 deletions qodana.yaml

This file was deleted.

76 changes: 0 additions & 76 deletions src/Laravel/DriverOld.php

This file was deleted.

1 change: 0 additions & 1 deletion src/Laravel/Events/RequestTerminated.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public function __construct(
} catch (BindingResolutionException) {
}
}

if ($sandbox->bound('session.store')) {
$app->forgetInstance('session.store');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Provider extends ServiceProvider
*/
public function register(): void
{
$this->commands([Driver::class, DriverOld::class]);
$this->commands([Driver::class]);
$this->app->singleton(Manager::class, static function () {
return new Manager();
});
Expand Down
2 changes: 1 addition & 1 deletion src/Laravel/Worker.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function register(Manager $manager): void
}

$this->server = $server;
$this->application = Application::getInstance();
$this->application = require base_path('bootstrap/app.php');

if (\Ripple\Driver\Utils\Config::value2bool(Config::get('ripple.HTTP_RELOAD'))) {
$monitor = IO::File()->watch();
Expand Down
3 changes: 1 addition & 2 deletions src/ThinkPHP/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ public function register(): void

// 注册终端
$this->commands([
'ripple:server' => Driver::class,
'p:server' => Driver::class
'ripple:server' => Driver::class
]);
}
}
42 changes: 0 additions & 42 deletions src/Workerman/Driver.php

This file was deleted.

53 changes: 23 additions & 30 deletions src/Workerman/Driver5.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,19 @@
namespace Ripple\Driver\Workerman;

use Co\System;
use Ripple\Kernel;
use Ripple\Utils\Output;
use Revolt\EventLoop;
use Revolt\EventLoop\UnsupportedFeatureException;
use Throwable;
use Ripple\Kernel;
use Ripple\Utils\Output;
use Workerman\Events\EventInterface;

use function array_shift;
use function Co\cancel;
use function Co\cancelAll;
use function Co\delay;
use function Co\repeat;
use function Co\stop;
use function Co\wait;
use function count;
use function getmypid;
use function pcntl_signal;
Expand All @@ -60,43 +64,32 @@ final class Driver5 implements EventInterface
private static int|float $baseProcessId;

/**
* All listeners for read event.
*
* @var array<int, string>
* @var array
*/
private array $readEvents = [];

/**
* All listeners for write event.
*
* @var array<int, string>
* @var array
*/
private array $writeEvents = [];

/**
* Event listeners of signal.
*
* @var array<int, string>
* @var array
*/
private array $eventSignal = [];

/**
* Event listeners of timer.
*
* @var array<int, string>
* @var array
*/
private array $eventTimer = [];

/**
* Timer id.
*
* @var int
*/
private int $timerId = 1;

/**
* @return void
* @throws Throwable
*/
public function run(): void
{
Expand All @@ -113,7 +106,7 @@ public function run(): void
}
}

\Co\wait();
wait();

while (1) {
sleep(1);
Expand All @@ -125,7 +118,7 @@ public function run(): void
*/
public function stop(): void
{
\Co\stop();
stop();
if (Kernel::getInstance()->supportProcessControl()) {
pcntl_signal(SIGINT, SIG_IGN);
}
Expand All @@ -145,7 +138,7 @@ public function delay(float $delay, callable $func, array $args = []): int
unset($this->eventTimer[$timerId]);
$func(...$args);
};
$cbId = \Co\delay($closure, $delay);
$cbId = delay($closure, $delay);
$this->eventTimer[$timerId] = $cbId;
return $timerId;
}
Expand All @@ -160,7 +153,7 @@ public function delay(float $delay, callable $func, array $args = []): int
public function repeat(float $interval, callable $func, array $args = []): int
{
$timerId = $this->timerId++;
$cbId = \Co\repeat(static fn () => $func(...$args), $interval);
$cbId = repeat(static fn () => $func(...$args), $interval);
$this->eventTimer[$timerId] = $cbId;
return $timerId;
}
Expand All @@ -175,7 +168,7 @@ public function onReadable($stream, callable $func): void
{
$fdKey = (int)$stream;
if (isset($this->readEvents[$fdKey])) {
\Co\cancel($this->readEvents[$fdKey]);
cancel($this->readEvents[$fdKey]);
unset($this->readEvents[$fdKey]);
}

Expand All @@ -191,7 +184,7 @@ public function offReadable($stream): bool
{
$fdKey = (int)$stream;
if (isset($this->readEvents[$fdKey])) {
\Co\cancel($this->readEvents[$fdKey]);
cancel($this->readEvents[$fdKey]);
unset($this->readEvents[$fdKey]);
return true;
}
Expand All @@ -208,7 +201,7 @@ public function onWritable($stream, callable $func): void
{
$fdKey = (int)$stream;
if (isset($this->writeEvents[$fdKey])) {
\Co\cancel($this->writeEvents[$fdKey]);
cancel($this->writeEvents[$fdKey]);
unset($this->writeEvents[$fdKey]);
}
$this->writeEvents[$fdKey] = EventLoop::onWritable($stream, static fn () => $func($stream));
Expand All @@ -223,7 +216,7 @@ public function offWritable($stream): bool
{
$fdKey = (int)$stream;
if (isset($this->writeEvents[$fdKey])) {
\Co\cancel($this->writeEvents[$fdKey]);
cancel($this->writeEvents[$fdKey]);
unset($this->writeEvents[$fdKey]);
return true;
}
Expand All @@ -241,7 +234,7 @@ public function onSignal(int $signal, callable $func): void
{
$fdKey = $signal;
if (isset($this->eventSignal[$fdKey])) {
\Co\cancel($this->eventSignal[$fdKey]);
cancel($this->eventSignal[$fdKey]);
unset($this->eventSignal[$fdKey]);
}
$this->eventSignal[$fdKey] = EventLoop::onSignal($signal, static fn () => $func($signal));
Expand All @@ -256,7 +249,7 @@ public function offSignal(int $signal): bool
{
$fdKey = $signal;
if (isset($this->eventSignal[$fdKey])) {
\Co\cancel($this->eventSignal[$fdKey]);
cancel($this->eventSignal[$fdKey]);
unset($this->eventSignal[$fdKey]);
return true;
}
Expand All @@ -281,7 +274,7 @@ public function offRepeat(int $timerId): bool
public function offDelay(int $timerId): bool
{
if (isset($this->eventTimer[$timerId])) {
\Co\cancel($this->eventTimer[$timerId]);
cancel($this->eventTimer[$timerId]);
unset($this->eventTimer[$timerId]);
return true;
}
Expand All @@ -294,7 +287,7 @@ public function offDelay(int $timerId): bool
public function deleteAllTimer(): void
{
while ($cbId = array_shift($this->eventTimer)) {
\Co\cancel($cbId);
cancel($cbId);
}
}

Expand Down
Loading

0 comments on commit 8523568

Please sign in to comment.