Giter VIP home page Giter VIP logo

pevents's Introduction

pevents is a cross-platform C++ 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 is
also free of spurious wakeups - returns from waits are guaranteed
correct.

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.

pevents is developed and maintained by Mahmoud Al-Qudsi
<[email protected]> of NeoSmart Technologies <http://neosmart.net/>

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.

Usage:

pevents comes with two APIs: one along the lines of WIN32 functions and
the other for those more comfortable with pthread functions. They are
identical underneath the hood.

WIN32-style pevents API:

	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);

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. (Windows users should use win32.cpp instead of
pevents.cpp)

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.

pevents's People

Contributors

mqudsi avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.