PHPackages                             switon/sync - 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. [Framework](/categories/framework)
4. /
5. switon/sync

ActiveLibrary[Framework](/categories/framework)

switon/sync
===========

In-process channels, mutexes, wait groups, and stacks for coroutine-aware coordination for Switon Framework

v1.0.0(1mo ago)0433MITPHPPHP &gt;=8.3CI passing

Since Jun 6Pushed 1mo agoCompare

[ Source](https://github.com/switon-php/sync)[ Packagist](https://packagist.org/packages/switon/sync)[ Docs](https://github.com/switon-php/sync)[ RSS](/packages/switon-sync/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (4)Versions (2)Used By (3)

Switon Sync Package
===================

[](#switon-sync-package)

[![CI](https://camo.githubusercontent.com/6c401e0f00ed6f44a7174be6743ee093a6b5580ca8714eb80f60dc8e776e6353/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f737769746f6e2d7068702f73796e632f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d4349)](https://github.com/switon-php/sync/actions/workflows/ci.yml) [![PHP 8.3+](https://camo.githubusercontent.com/c03f51341eebaefabbf137e291b20523fc74b4ffd084406d88524d266d95085d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d373737424234)](https://www.php.net/)

Switon's synchronization primitives for bounded handoff, mutual exclusion, task joining, and LIFO reuse in coroutine and non-coroutine runtimes.

Highlights
----------

[](#highlights)

- **Coroutine-friendly primitives:** the same contracts work in coroutine and non-coroutine runtimes.
- **Bounded channels:** `Channel` provides fixed-capacity FIFO handoff.
- **Scoped mutexes:** `Mutex::guard()` returns a lock for deterministic release.
- **Task joining:** `WaitGroup` blocks until registered work finishes.
- **LIFO reuse:** `Stack` provides fixed-capacity last-in-first-out reuse.

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

[](#installation)

```
composer require switon/sync
```

Quick Start
-----------

[](#quick-start)

```
use Switon\Sync\Channel;
use Switon\Sync\Mutex;
use Switon\Sync\WaitGroup;

$channel = new Channel(2);
$channel->push('task-1');
$task = $channel->pop();

$mutex = new Mutex();
$lock = $mutex->guard();
try {
    // critical section
} finally {
    $lock->release();
}

$wg = WaitGroup::of(2);
$wg->done();
$wg->done();
$wg->wait();
```

Docs:

License
-------

[](#license)

MIT.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance90

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

48d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dc0f20ad15b0ae9fbf9c6e2cd3008692b0c88a877ec8d3e0119211314bf86fc8?d=identicon)[switon](/maintainers/switon)

---

Top Contributors

[![switon-php](https://avatars.githubusercontent.com/u/247358032?v=4)](https://github.com/switon-php "switon-php (1 commits)")

---

Tags

channelsmutexswitonsyncsynchronizationsynchronizationmutexchannelsswiton

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/switon-sync/health.svg)

```
[![Health](https://phpackages.com/badges/switon-sync/health.svg)](https://phpackages.com/packages/switon-sync)
```

###  Alternatives

[amphp/sync

Non-blocking synchronization primitives for PHP based on Amp and Revolt.

19261.0M55](/packages/amphp-sync)[yiisoft/mutex

Yii Mutex Library

34164.0k11](/packages/yiisoft-mutex)[yiisoft/mutex-file

Yii Mutex Library - File Driver

114.7k2](/packages/yiisoft-mutex-file)[yiisoft/mutex-pdo-pgsql

Yii Mutex Library - Postgres PDO Driver

102.9k](/packages/yiisoft-mutex-pdo-pgsql)

PHPackages © 2026

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