innmind/async-operating-system
最新稳定版本:1.0.0
Composer 安装命令:
composer require innmind/async-operating-system
包简介
README 文档
README
Async implementation of innmind/operating-system to allow to switch to another task when doing any I/O of suspending the current process.
Warning: the following features are disabled in this async context :
- Process forking
- Handling signals
Note: SQL connections are not async yet.
Installation
composer require innmind/async-operating-system
Usage
use Innmind\Async\OperatingSystem\Factory; use Innmind\OperatingSystem\Factory as Synchronous; use Innmind\Filesystem\Name; use Innmind\Http\{ Message\Request\Request, Message\Method, ProtocolVersion, }; use Innmind\Url\{ Url, Path, }; use Innmind\Mantle\{ Source\Predetermined, Suspend, Forerunner, }; $synchronous = Synchronous::build(); $factory = Factory::of($synchronous); $source = Predetermined::of( static fn(Suspend $suspend) => $factory ->build($suspend) ->filesystem() ->mount(Path::of('somewhere/')) ->get(Name::of('some-file')) ->match( static fn($file) => doYourStuff($file), static fn() => null, ), static fn(Suspend $suspend) => $factory ->build($suspend) ->remote() ->http()(new Request( Url::of('https://wikipedia.org') Method::get, ProtocolVersion::v11, )) ->match( static fn($success) => doYourStuff($success), static fn() => null, ); ); Forerunner::of($synchronous->clock())(null, $source);
In this example we load a file and call wikipedia asynchronously, but you can use the OperatingSystem returned by $factory->build($suspend) like you would for its synchronous counterpart.
统计信息
- 总下载量: 643
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-02-04