{"id":15022267,"url":"https://github.com/php/pecl-system-sync","last_synced_at":"2026-03-13T01:31:14.106Z","repository":{"id":18329564,"uuid":"21508730","full_name":"php/pecl-system-sync","owner":"php","description":"Synchronization objects","archived":false,"fork":false,"pushed_at":"2024-07-05T21:17:24.000Z","size":39,"stargazers_count":20,"open_issues_count":6,"forks_count":12,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-10-23T00:36:47.294Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://pecl.php.net/package/sync","language":"C","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/php.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-07-04T22:15:24.000Z","updated_at":"2025-09-27T20:03:02.000Z","dependencies_parsed_at":"2024-11-07T01:25:25.082Z","dependency_job_id":"030f2db7-4aa4-4ca6-9dd7-7bc4418cf0cb","html_url":"https://github.com/php/pecl-system-sync","commit_stats":{"total_commits":23,"total_committers":4,"mean_commits":5.75,"dds":"0.26086956521739135","last_synced_commit":"36d5be0e337fab6b0cc37e1ed66849429712846c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/php/pecl-system-sync","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php%2Fpecl-system-sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php%2Fpecl-system-sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php%2Fpecl-system-sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php%2Fpecl-system-sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php","download_url":"https://codeload.github.com/php/pecl-system-sync/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php%2Fpecl-system-sync/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30453547,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T21:31:01.033Z","status":"ssl_error","status_checked_at":"2026-03-12T21:30:43.161Z","response_time":114,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2024-09-24T19:57:43.210Z","updated_at":"2026-03-13T01:31:14.078Z","avatar_url":"https://github.com/php.png","language":"C","readme":"CubicleSoft PHP Extension:  Synchronization Objects (sync)\n==========================================================\n\nThe 'sync' extension introduces synchronization objects into PHP.  Named and unnamed Mutex, Semaphore, Event, Reader-Writer, and named Shared Memory objects provide OS-level synchronization mechanisms on both *NIX (POSIX shared memory and pthread shared memory synchronization required) and Windows platforms.  The extension comes with a test suite that integrates cleanly into 'make test'.\n\nThe 'sync' extension is a direct port of and compatible with the cross platform 'sync' library:  https://github.com/cubiclesoft/cross-platform-cpp\n\nThis extension uses the liberal MIT open source license.  And, of course, it sits on GitHub for all of that pull request and issue tracker goodness to easily submit changes and ideas respectively.\n\nDetails\n-------\n\nAn exception may be thrown from the constructors if the target object can't be created for some reason.\n\nAll synchronization objects are attempted to be unlocked cleanly within PHP itself.  The exception is if an object's $autounlock option is initialized to false.  If PHP terminates a script and doesn't unlock the object, it can leave the object in an unpredictable state.\n\nNOTE:  When using \"named\" objects, the initialization must be identical for a given name and have a specific purpose.  Reusing named objects for other purposes is not a good idea and will probably result in breaking both applications.  However, different object types can share the same name (e.g. a Mutex and an Event object can have the same name).\n\n````\nvoid SyncMutex::__construct([string $name = null])\n  Constructs a named or unnamed mutex object.\n\nbool SyncMutex::lock([int $wait = -1])\n  Locks a mutex object.  $wait is in milliseconds.\n\nbool SyncMutex::unlock([bool $all = false])\n  Unlocks a mutex object.\n\n\nvoid SyncSemaphore::__construct([string $name = null, [int $initialval = 1, [bool $autounlock = true]]])\n  Constructs a named or unnamed semaphore object.  Don't set $autounlock to false unless you really know what you are doing.\n\nbool SyncSemaphore::lock([int $wait = -1])\n  Locks a semaphore object.  $wait is in milliseconds.\n\nbool SyncSemaphore::unlock([int \u0026$prevcount])\n  Unlocks a semaphore object.\n\n\nvoid SyncEvent::__construct([string $name = null, [bool $manual = false], [bool $prefire = false]])\n  Constructs a named or unnamed event object.\n\nbool SyncEvent::wait([int $wait = -1])\n  Waits for an event object to fire.  $wait is in milliseconds.\n\nbool SyncEvent::fire()\n  Lets a thread through that is waiting.  Lets multiple threads through that are waiting if the event object is 'manual'.\n\nbool SyncEvent::reset()\n  Resets the event object state.  Only use when the event object is 'manual'.\n\n\nvoid SyncReaderWriter::__construct([string $name = null, [bool $autounlock = true]])\n  Constructs a named or unnamed reader-writer object.  Don't set $autounlock to false unless you really know what you are doing.\n\nbool SyncReaderWriter::readlock([int $wait = -1])\n  Read locks a reader-writer object.  $wait is in milliseconds.\n\nbool SyncReaderWriter::writelock([int $wait = -1])\n  Write locks a reader-writer object.  $wait is in milliseconds.\n\nbool SyncReaderWriter::readunlock()\n  Read unlocks a reader-writer object.\n\nbool SyncReaderWriter::writeunlock()\n  Write unlocks a reader-writer object.\n\n\nvoid SyncSharedMemory::__construct(string $name, int $size)\n  Constructs a named shared memory object.\n\nbool SyncSharedMemory::first()\n  Returns whether or not this shared memory segment is the first time accessed (i.e. not initialized).\n\nint SyncSharedMemory::size()\n  Returns the shared memory size.\n\nint SyncSharedMemory::write(string $string, [int $start = 0])\n  Copies data to shared memory.\n\nstring SyncSharedMemory::read([int $start = 0, [int $length = null]])\n  Copies data from shared memory.\n````\n\nUsage Examples\n--------------\n\nExample Mutex usage:\n\n```php\n$mutex = new SyncMutex();\n\n$mutex-\u003elock();\n...\n$mutex-\u003eunlock();\n\n\n$mutex2 = new SyncMutex(\"UniqueName\");\n\nif (!$mutex2-\u003elock(3000))\n{\n\techo \"Unable to lock mutex.\";\n\n\texit();\n}\n\n...\n\n$mutex2-\u003eunlock();\n```\n\nExample Semaphore usage:\n\n```php\n$semaphore = new SyncSemaphore(\"LimitedResource_2_clients\", 2);\n\nif (!$semaphore-\u003elock(3000))\n{\n\techo \"Unable to lock semaphore.\";\n\n\texit();\n}\n\n...\n\n$semaphore-\u003eunlock();\n```\n\nExample Event usage:\n\n```php\n// In a web application:\n$event = new SyncEvent(\"GetAppReport\");\n$event-\u003efire();\n\n// In a cron job:\n$event = new SyncEvent(\"GetAppReport\");\n$event-\u003ewait();\n```\n\nExample Reader-Writer usage:\n\n```php\n$readwrite = new SyncReaderWriter(\"FileCacheLock\");\n$readwrite-\u003ereadlock();\n...\n$readwrite-\u003ereadunlock();\n\n$readwrite-\u003ewritelock();\n...\n$readwrite-\u003ewriteunlock();\n```\n\nExample Shared Memory usage:\n\n```php\n// You will probably need to protect shared memory with other synchronization objects.\n// Shared memory goes away when the last reference to it disappears.\n$mem = new SyncSharedMemory(\"AppReportName\", 1024);\nif ($mem-\u003efirst())\n{\n\t// Do first time initialization work here.\n}\n\n$result = $mem-\u003ewrite(json_encode(array(\"name\" =\u003e \"my_report.txt\")));\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp%2Fpecl-system-sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp%2Fpecl-system-sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp%2Fpecl-system-sync/lists"}