All Projects → neosmart → Pevents

neosmart / Pevents

Licence: mit
Implementation of Win32 events for *nix platforms, built on top of pthreads.

Projects that are alternatives of or similar to Pevents

Xtd forms
Modern c++17 library to create native gui for Microsoft Windows, Apple macOS and Linux.
Stars: ✭ 25 (-87.5%)
Mutual labels:  events, cross-platform
Nighthawk
A stealthy, simple, unobtrusive music player that stays out of your way
Stars: ✭ 197 (-1.5%)
Mutual labels:  cross-platform
Spotlightify
The Spotify overlay controller
Stars: ✭ 190 (-5%)
Mutual labels:  cross-platform
Timemory
Modular C++ Toolkit for Performance Analysis and Logging. Profiling API and Tools for C, C++, CUDA, Fortran, and Python. The C++ template API is essentially a framework to creating tools: it is designed to provide a unifying interface for recording various performance measurements alongside data logging and interfaces to other tools.
Stars: ✭ 192 (-4%)
Mutual labels:  cross-platform
Fishengine
Simple, Unity-like Game Engine.
Stars: ✭ 191 (-4.5%)
Mutual labels:  cross-platform
Event Driven Spring Boot
Example Application to demo various flavours of handling domain events in Spring Boot
Stars: ✭ 194 (-3%)
Mutual labels:  events
Camera awesome
A flutter plugin to handle Android / iOS camera
Stars: ✭ 186 (-7%)
Mutual labels:  cross-platform
Outwiker
Сross-platform software for keeping your notes in a tree
Stars: ✭ 198 (-1%)
Mutual labels:  cross-platform
Netlink
Socket and Networking Library using msgpack.org[C++11]
Stars: ✭ 197 (-1.5%)
Mutual labels:  cross-platform
Svelte Nodegui
Build performant, native and cross-platform desktop applications with native Svelte + powerful CSS-like styling.🚀
Stars: ✭ 2,598 (+1199%)
Mutual labels:  cross-platform
Library
This is a project of a library, driven by real business requirements. We use techniques strongly connected with Domain Driven Design, Behavior-Driven Development, Event Storming, User Story Mapping.
Stars: ✭ 2,685 (+1242.5%)
Mutual labels:  events
Swift
Swift XMPP client and Swiften XMPP library
Stars: ✭ 190 (-5%)
Mutual labels:  cross-platform
X3py
C++ Plugin Framework that can integrate with QT, Python, Java or C#.
Stars: ✭ 195 (-2.5%)
Mutual labels:  cross-platform
Open Source Meetup Alternatives
Open-Source Alternatives to Meetup
Stars: ✭ 191 (-4.5%)
Mutual labels:  events
Wikitude Cordova Plugin
Wikitude's Augmented Reality Plugin for Cordova - working together with the Wikitude SDK library for Android and iOS. Provides image recognition and tracking, geo-based augmente reality and 3D rendering and animations in an augmented reality scene
Stars: ✭ 197 (-1.5%)
Mutual labels:  cross-platform
Youi
Next generation user interface and application development in Scala and Scala.js for web, mobile, and desktop.
Stars: ✭ 186 (-7%)
Mutual labels:  cross-platform
Hello Weex
hello-weex包括一个Weex App(GitHub第三方App),和自己扩展的WeexiOSKit(iOS上的常用组件与模块)。
Stars: ✭ 193 (-3.5%)
Mutual labels:  cross-platform
Penguin Subtitle Player
An open-source, cross-platform standalone subtitle player
Stars: ✭ 194 (-3%)
Mutual labels:  cross-platform
Mednaffe
A front-end (GUI) for mednafen emulator
Stars: ✭ 200 (+0%)
Mutual labels:  cross-platform
Methanekit
🎲 Modern 3D graphics made simple with cross-platform C++17 meta-API on top of DirectX 12 & Metal (Vulkan is coming)
Stars: ✭ 197 (-1.5%)
Mutual labels:  cross-platform

pevents

pevents is a cross-platform low-level library meant to provide an implementation of the WIN32 events for POSIX systems. pevents is built on pthreads and provides most of the functionality of both manual- and auto-reset events on Windows, most-notably including simultaneous waits on multiple events (à la WaitForMultipleObjects).

pevents also doubles as a thin, sane wrapper for CreateEvent() & co. on Windows, meaning you can use pevents directly in your cross-platform code without #ifdefs for Windows/pthreads.

License and Authorship

pevents is developed and maintained by Mahmoud Al-Qudsi <[email protected]> of NeoSmart Technologies <https://neosmart.net/> and is distributed under the open source MIT public license. Refer to the LICENSE file for more information.

About pevents

While POSIX condition variables (pthread_cond_t) and WIN32 events both provide the essential building blocks of the synchronization primitives required to write multithreaded code with signaling, the nature of the differences between the two have lent their way towards creating different synchronization and multithreaded-programming paradigms.

Developers accustomed to WIN32 events might have a hard time transitioning to condition variables; pevents aims to ease the transition for Windows developers looking to write multithreaded code on *nix by providing a familiar synchronization primitive that will allow them to duplicate the essential features of WIN32 auto/manual-reset events.

As mentioned earlier, pevents provides most of the functionality of WIN32 events. The only features not included are only named events and support for security attributes. To the author's best knowledge, this is the only implementation of WIN32 events available for Linux and other posix platforms that provides support for simultaneously waiting on multiple events.

Depending on your needs, we've been told that pevents may be used as a lightweight alternative to libuv/libev while still allowing your code to embrace asynchronous event handling with ease.

Supported platforms

pevents has been used as an extremely simple and lightweight cross-platform synchronization library in code used across multiple platforms (including Windows, FreeBSD, Linux, macOS, iOS, Android, and more).

pevents API

The pevents API is modeled after the Windows CreateEvent(), WaitForSingleObject(), and WaitForMultipleObjects() functions. Users familiar with WIN32 events should have no problem switching the codebase over to the pevents API.

Additionally, pevents is also free of spurious wakeups - returns from waits are guaranteed correct¹.

¹ Spurious wakeups are a normal part of system programming under Linux, and a common pitfall for developers coming from the Windows world.

neosmart_event_t CreateEvent(bool manualReset, bool initialState);

int DestroyEvent(neosmart_event_t event);

int WaitForEvent(neosmart_event_t event, uint64_t milliseconds);

int WaitForMultipleEvents(neosmart_event_t *events, int count,
		bool waitAll, uint64_t milliseconds);

int WaitForMultipleEvents(neosmart_event_t *events, int count,
		bool waitAll, uint64_t milliseconds, int &index);

int SetEvent(neosmart_event_t event);

int ResetEvent(neosmart_event_t event);

int PulseEvent(neosmart_event_t event);

Building and using pevents

All the code is contained within pevents.cpp and pevents.h. You should include these two files in your project as needed. All functions are in the neosmart namespace.

Code structure

  • Core pevents code is in the src/ directory
  • Unit tests (deployable via meson) are in tests/
  • A sample cross-platform application demonstrating the usage of pevents can be found in the examples/ folder. More examples are to come. (Pull requests welcomed!)

Optional build system

Experimental support for building pevents via the meson build system has recently landed. Currently, this is only used to support automated building/testing of pevents core and its supporting utilities and unit tests. To repeat: do not worry about the build system, pevents is purposely written in plain C/C++ and avoids the need for complex configuration or platform-dependent build instructions.

Compilation options:

The following preprocessor definitions may be defined (-DOPTION) at compile time to enable different features.

  • WFMO: Enables WFMO support in pevents. It is recommended to only compile with WFMO support if you are taking advantage of the WaitForMultipleEvents function, as it adds a (small) overhead to all event objects.

  • PULSE: Enables the PulseEvent function. PulseEvent() on Windows is fundamentally broken and should not be relied upon — it will almost never do what you think you're doing when you call it. pevents includes this function only to make porting existing (flawed) code from WIN32 to *nix platforms easier, and this function is not compiled into pevents by default.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].