PHPackages                             reinfyteam/libvapm-pmmp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. reinfyteam/libvapm-pmmp

ActiveProject

reinfyteam/libvapm-pmmp
=======================

02311PHPCI passing

Since Apr 12Pushed 2mo agoCompare

[ Source](https://github.com/ReinfyTeam/LibVapmPMMP)[ Packagist](https://packagist.org/packages/reinfyteam/libvapm-pmmp)[ RSS](/packages/reinfyteam-libvapm-pmmp/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (1)DependenciesVersions (1)Used By (0)

LibVapmPMMP
===========

[](#libvapmpmmp)

Async/Promise/Coroutine/Thread utilities for PocketMine-MP (virion-ready).

Requirements
------------

[](#requirements)

- PMMP API: `5.0.0`
- PHP: `8.1 - 8.4`

Installation
------------

[](#installation)

### Composer

[](#composer)

```
composer require reinfyteam/libvapm-pmmp
```

### Virion

[](#virion)

- Download from Poggit:
- Place the virion in your project virions folder.

Quick setup
-----------

[](#quick-setup)

Initialize once in your plugin:

```
use pocketmine\plugin\PluginBase;
use vennv\vapm\VapmPMMP;

final class Main extends PluginBase{
    protected function onEnable() : void{
        VapmPMMP::init($this);
    }
}
```

`VapmPMMP::init()` registers the repeating event-loop tick task. Calling it more than once (or with a different plugin instance) is guarded and will emit a warning.

Recommended imports
-------------------

[](#recommended-imports)

```
use vennv\vapm\VapmPMMP;
use vennv\vapm\io\Io;
use vennv\vapm\ct\Ct;
use vennv\vapm\Promise;
use vennv\vapm\System;
```

Usage
-----

[](#usage)

### 1) Async + await (Io facade)

[](#1-async--await-io-facade)

```
$job = Io::async(function () : string {
    return "done";
});

$result = Io::await($job); // "done"
```

### 2) Delay / timers

[](#2-delay--timers)

```
Io::setTimeout(function () : void {
    // run once after delay
}, 50);

Io::setInterval(function () : void {
    // run repeatedly
}, 20);

Io::delay(100)->then(function () : void {
    // delayed promise flow
});
```

### 3) Coroutines (Ct facade)

[](#3-coroutines-ct-facade)

```
use Generator;

Ct::c(function () : Generator {
    yield from Ct::cDelay(10);
    // coroutine work
});

Ct::cBlock(function () : Generator {
    yield from Ct::cDelay(5);
    // blocking coroutine run
});
```

### 4) Promise composition

[](#4-promise-composition)

```
$all = Promise::all([
    Io::async(fn() => 1),
    Io::async(fn() => 2),
]);

$values = Io::await($all); // [1, 2]
```

Also available: `Promise::allSettled()`, `Promise::any()`, `Promise::race()`.

### 5) HTTP/file helpers (System)

[](#5-httpfile-helpers-system)

```
System::fetch("https://example.com")->then(function ($response) : void {
    // InternetRequestResult
});

System::read("/path/to/file.txt")->then(function (string $content) : void {
    // file contents
});
```

&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD

Quick-start recipes
-------------------

[](#quick-start-recipes)

### Timeout + fallback

[](#timeout--fallback)

```
Io::delay(100)->then(function () : void {
    // do primary operation
})->finally(function () : void {
    // cleanup
});
```

### Repeating interval with stop

[](#repeating-interval-with-stop)

```
$task = System::setInterval(function () : void {
    // heartbeat
}, 20);

System::setTimeout(function () use ($task) : void {
    System::clearInterval($task);
}, 200);
```

### Parallel awaits

[](#parallel-awaits)

```
$result = Io::await(Promise::all([
    Io::async(fn() => "A"),
    Io::async(fn() => "B"),
]));
```

### Fetch with explicit timeout

[](#fetch-with-explicit-timeout)

```
System::fetch("https://example.com", [
    "method" => "GET",
    "timeout" => 5,
])->then(function ($response) : void {
    // InternetRequestResult
});
```

High-volume queue and backpressure notes
----------------------------------------

[](#high-volume-queue-and-backpressure-notes)

1. Promise queue de-duplicates enqueues by Promise ID.
2. Scheduler fairness is backlog-aware across Promise, coroutine, microtask, and macrotask queues.
3. For large producers, tune chunking with `Settings::setWorkDrainChunkSize()` and `Settings::setWorkerProducerChunkSize()`.
4. For low-end hosts, cap per-tick work with `Settings::setEventLoopLimits()`, `Settings::setMacroTaskLimits()`, and `Settings::setCoroutineLimits()`.

Scheduler metrics and diagnostics
---------------------------------

[](#scheduler-metrics-and-diagnostics)

```
use vennv\vapm\EventLoop;
use vennv\vapm\Settings;

Settings::setSchedulerDebug(true);
Settings::setDebugLogIntervalTicks(20);
Settings::setHealthWarnBacklogThreshold(10000);
Settings::setHealthWarnDropThreshold(100);

$snapshot = EventLoop::getMetricsSnapshot();
// queueDepth, coroutineBacklog, microTaskBacklog, macroTaskBacklog, drops, processed counters...
```

Static analysis gates:

```
composer analyse-src
composer analyse-scheduler
```

PocketMine-MP API 5 compatibility notes
---------------------------------------

[](#pocketmine-mp-api-5-compatibility-notes)

1. `VapmPMMP::init()` is designed for API 5 tick scheduling (`scheduleRepeatingTask(..., 1)`).
2. In PMMP-managed mode, system-level tick/shutdown hooks are not auto-registered; PMMP scheduler drives the loop.
3. In non-PMMP contexts, runtime hooks are attempted; if unavailable, LibVapmPMMP emits warnings and expects manual loop runs.

Compatibility check script:

```
composer compat-api5
```

Stress scripts and benchmark comparison notes
---------------------------------------------

[](#stress-scripts-and-benchmark-comparison-notes)

Run deterministic stress workloads:

```
composer benchmark-queue
composer benchmark-mixed
```

For before/after comparisons:

```
# before
git checkout
composer benchmark-compare

# after
git checkout
composer benchmark-compare
```

Capture both JSON outputs and compare:

- `metrics.totalBacklog`, `metrics.queueDepth`, `metrics.processed*`
- `metrics.droppedReturns`, `metrics.droppedDuplicateQueue`

For optimization roadmap and upcoming improvements, see [`WATCHLIST.md`](WATCHLIST.md).
=======================================================================================

[](#for-optimization-roadmap-and-upcoming-improvements-see-watchlistmd)

Notes for high-throughput workloads
-----------------------------------

[](#notes-for-high-throughput-workloads)

- Keep long operations async/coroutine-based.
- Prefer batching and composition (`Promise::all`, channels, await groups) over deep nested callbacks.
- For optimization roadmap and upcoming improvements, see [`WATCHLIST.md`](WATCHLIST.md).

> > > > > > > a01e0333b855038f1e6535c0724a400d2f919db9

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance56

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 Bus Factor1

Top contributor holds 92.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/143252455?v=4)[Rodolfo Orlanda Jr.](/maintainers/rodolfoorlandajr)[@rodolfoorlandajr](https://github.com/rodolfoorlandajr)

---

Top Contributors

[![VennDev](https://avatars.githubusercontent.com/u/111500380?v=4)](https://github.com/VennDev "VennDev (511 commits)")[![xRodzMC](https://avatars.githubusercontent.com/u/100104970?v=4)](https://github.com/xRodzMC "xRodzMC (16 commits)")[![0xliam627](https://avatars.githubusercontent.com/u/70517151?v=4)](https://github.com/0xliam627 "0xliam627 (12 commits)")[![rodolfoorlandajr](https://avatars.githubusercontent.com/u/143252455?v=4)](https://github.com/rodolfoorlandajr "rodolfoorlandajr (11 commits)")[![NhanAZ](https://avatars.githubusercontent.com/u/60387689?v=4)](https://github.com/NhanAZ "NhanAZ (2 commits)")[![poggit-bot](https://avatars.githubusercontent.com/u/22427965?v=4)](https://github.com/poggit-bot "poggit-bot (2 commits)")

### Embed Badge

![Health badge](/badges/reinfyteam-libvapm-pmmp/health.svg)

```
[![Health](https://phpackages.com/badges/reinfyteam-libvapm-pmmp/health.svg)](https://phpackages.com/packages/reinfyteam-libvapm-pmmp)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
