{"id":13700134,"url":"https://github.com/leocavalcante/swoole-mutex","last_synced_at":"2025-04-23T07:30:18.371Z","repository":{"id":57013896,"uuid":"254894918","full_name":"leocavalcante/swoole-mutex","owner":"leocavalcante","description":"🚦 Mutual exclusion abstractions for PHP's Swoole concurrency run-time.","archived":false,"fork":false,"pushed_at":"2020-04-11T20:05:27.000Z","size":32,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T22:41:18.968Z","etag":null,"topics":["concurrency","mutex","php","swoole"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leocavalcante.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-11T15:16:22.000Z","updated_at":"2024-09-15T19:22:14.000Z","dependencies_parsed_at":"2022-08-22T10:11:02.591Z","dependency_job_id":null,"html_url":"https://github.com/leocavalcante/swoole-mutex","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leocavalcante%2Fswoole-mutex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leocavalcante%2Fswoole-mutex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leocavalcante%2Fswoole-mutex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leocavalcante%2Fswoole-mutex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leocavalcante","download_url":"https://codeload.github.com/leocavalcante/swoole-mutex/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250390741,"owners_count":21422769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["concurrency","mutex","php","swoole"],"created_at":"2024-08-02T20:00:48.935Z","updated_at":"2025-04-23T07:30:18.346Z","avatar_url":"https://github.com/leocavalcante.png","language":"PHP","funding_links":[],"categories":["Miscellaneous"],"sub_categories":[],"readme":"# Mutex\n\n[![Actions Status](https://github.com/leocavalcante/swoole-mutex/workflows/CI/badge.svg)](https://github.com/leocavalcante/swoole-mutex/actions)\n\n🚦 [Mutual exclusion](https://en.wikipedia.org/wiki/Mutual_exclusion) abstractions for PHP's [Swoole](https://www.swoole.co.uk/) concurrency run-time.\n\n\u003e With great power comes great responsibility — Uncle Ben (I guess)\n\n[Swoole](https://www.swoole.co.uk/) awesomeness enables concurrency across multiple processes and cores, but sharing state/memory between them isn't a straightforward achievement. [`Swoole\\Table`](https://www.swoole.co.uk/docs/modules/swoole-table) comes to help, but maybe we could have an even better API for that task.\n\n**This package is a [Facade](https://en.wikipedia.org/wiki/Facade_pattern) for [`Swoole\\Table`](https://www.swoole.co.uk/docs/modules/swoole-table) providing common APIs for mutual exclusion patterns.**\n\n_We all hail [**Edsger W. Dijkstra**](https://en.wikipedia.org/wiki/Edsger_W._Dijkstra) (and [Swoole team](https://github.com/orgs/swoole/people) for their amazing work)._\n\n## Install\n\n```bash\ncomposer require leocavalcante/swoole-mutex\n```\n\n## Example\n\nCounting HTTP requests across \u003e1 workers.\n\n```php\nuse Mutex\\Atomic\\Integer;\nuse Swoole\\Http\\{Request, Response, Server};\n\n$counter = new Integer();\n$server = new Server('127.0.0.1', 8000);\n\n$server-\u003eon('request', function (Request $req, Response $res) use ($counter): void {\n    if ($req-\u003eserver['request_uri'] !== '/favicon.ico') {\n        $counter-\u003einc();\n    }\n\n    $res-\u003eend('You are number: ' . $counter-\u003evalue());\n});\n\n$server-\u003eset(['worker_num' =\u003e 4]);\n$server-\u003estart();\n```\n\n---\n\n\u0026copy; 2k2O\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleocavalcante%2Fswoole-mutex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleocavalcante%2Fswoole-mutex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleocavalcante%2Fswoole-mutex/lists"}