{"id":13466644,"url":"https://github.com/neosmart/pevents","last_synced_at":"2025-04-07T05:15:14.802Z","repository":{"id":1739392,"uuid":"2564851","full_name":"neosmart/pevents","owner":"neosmart","description":"Implementation of Win32 events for *nix platforms, built on top of pthreads.","archived":false,"fork":false,"pushed_at":"2022-11-17T21:02:03.000Z","size":149,"stargazers_count":273,"open_issues_count":6,"forks_count":84,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-03-31T04:06:25.299Z","etag":null,"topics":["cross-platform","events","pthreads","synchronization","synchronization-primitives"],"latest_commit_sha":null,"homepage":"","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/neosmart.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":"2011-10-12T19:40:54.000Z","updated_at":"2025-03-24T06:25:17.000Z","dependencies_parsed_at":"2022-09-07T18:00:28.700Z","dependency_job_id":null,"html_url":"https://github.com/neosmart/pevents","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neosmart%2Fpevents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neosmart%2Fpevents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neosmart%2Fpevents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neosmart%2Fpevents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neosmart","download_url":"https://codeload.github.com/neosmart/pevents/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247595335,"owners_count":20963943,"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":["cross-platform","events","pthreads","synchronization","synchronization-primitives"],"created_at":"2024-07-31T15:00:47.641Z","updated_at":"2025-04-07T05:15:14.767Z","avatar_url":"https://github.com/neosmart.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"# pevents\n\n`pevents` is a cross-platform low-level library meant to provide an\nimplementation of the WIN32 events for POSIX systems. pevents is built\non pthreads and provides *most* of the functionality of both manual-\nand auto-reset events on Windows, most-notably including simultaneous\nwaits on multiple events (à la `WaitForMultipleObjects`).\n\npevents also doubles as a thin, sane wrapper for `CreateEvent()` \u0026 co. on\nWindows, meaning you can use pevents directly in your cross-platform\ncode without `#ifdefs` for Windows/pthreads.\n\n## License and Authorship\n\npevents is developed and maintained by Mahmoud Al-Qudsi\n\\\u003c[mqudsi@neosmart.net](mailto:mqudsi@neosmart.net)\\\u003e of NeoSmart Technologies\n\\\u003c[https://neosmart.net/](https://neosmart.net/)\\\u003e and is distributed under the\nopen source MIT public license. Refer to the `LICENSE` file for more information.\n\n## About pevents\n\nWhile POSIX condition variables (`pthread_cond_t`) and WIN32 events both\nprovide the essential building blocks of the synchronization primitives\nrequired to write multithreaded code with signaling, the nature of the\ndifferences between the two have lent their way towards creating\ndifferent synchronization and multithreaded-programming paradigms.\n\nDevelopers accustomed to WIN32 events might have a hard time\ntransitioning to condition variables; pevents aims to ease the\ntransition for Windows developers looking to write multithreaded code on\n*nix by providing a familiar synchronization primitive that will allow\nthem to duplicate the essential features of WIN32 auto/manual-reset\nevents.\n\nAs mentioned earlier, pevents provides most of the functionality of\nWIN32 events. The only features not included are only named events and\nsupport for security attributes. To the author's best knowledge, this is the only\nimplementation of WIN32 events available for Linux and other posix platforms\nthat provides support for simultaneously waiting on multiple events.\n\nDepending on your needs, we've been told that pevents may be used as a lightweight\nalternative to libuv/libev while still allowing your code to embrace asynchronous event\nhandling with ease.\n\n### Supported platforms\n\npevents has been used as an extremely simple and lightweight cross-platform synchronization\nlibrary in code used across multiple platforms (including Windows, FreeBSD, Linux, macOS,\niOS, Android, and more).\n## pevents API\n\nThe pevents API is modeled after the Windows `CreateEvent()`, `WaitForSingleObject()`,\nand `WaitForMultipleObjects()` functions. Users familiar with WIN32 events\nshould have no problem switching the codebase over to the pevents API.\n\nAdditionally, pevents is also free of spurious wakeups - returns from waits are guaranteed\ncorrect¹.\n\n¹ *Spurious wakeups are a normal part of system programming under\nLinux, and a common pitfall for developers coming from the Windows world.*\n\n```cpp\nneosmart_event_t CreateEvent(bool manualReset, bool initialState);\n\nint DestroyEvent(neosmart_event_t event);\n\nint WaitForEvent(neosmart_event_t event, uint64_t milliseconds);\n\nint WaitForMultipleEvents(neosmart_event_t *events, int count,\n\t\tbool waitAll, uint64_t milliseconds);\n\nint WaitForMultipleEvents(neosmart_event_t *events, int count,\n\t\tbool waitAll, uint64_t milliseconds, int \u0026index);\n\nint SetEvent(neosmart_event_t event);\n\nint ResetEvent(neosmart_event_t event);\n\nint PulseEvent(neosmart_event_t event);\n```\n\n## Building and using pevents\n\nAll the code is contained within `pevents.cpp` and `pevents.h`. You should\ninclude these two files in your project as needed. All functions are in\nthe `neosmart` namespace.\n\n### Code structure\n\n* Core `pevents` code is in the `src/` directory\n* Unit tests (deployable via meson) are in `tests/`\n* A sample cross-platform application demonstrating the usage of pevents can be found\nin the `examples/` folder. More examples are to come. (Pull requests welcomed!)\n\n### Optional build system\n\nExperimental support for building pevents via the meson build system has recently landed.\nCurrently, this is only used to support automated building/testing of pevents core and\nits supporting utilities and unit tests. To repeat: do not worry about the build system,\npevents is purposely written in plain C/C++ and avoids the need for complex configuration\nor platform-dependent build instructions.\n\n### Compilation options:\n\nThe following preprocessor definitions may be defined (`-DOPTION`) at\ncompile time to enable different features.\n\n* `WFMO`: Enables WFMO support in pevents. It is recommended to only compile\nwith WFMO support if you are taking advantage of the\n`WaitForMultipleEvents` function, as it adds a (small) overhead to all\nevent objects.\n\n* `PULSE`: Enables the `PulseEvent` function. `PulseEvent()` on Windows is\nfundamentally broken and should not be relied upon — it will almost\nnever do what you think you're doing when you call it. pevents includes\nthis function only to make porting existing (flawed) code from WIN32 to\n*nix platforms easier, and this function is not compiled into pevents by\ndefault.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneosmart%2Fpevents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneosmart%2Fpevents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneosmart%2Fpevents/lists"}