GithubHelp home page GithubHelp logo

rush / cpp-eventemitter Goto Github PK

View Code? Open in Web Editor NEW
7.0 4.0 2.0 38 KB

Attach lightweight C++11 event emitting and handling capabilities to your existing C++ classes.

C++ 96.24% Perl 2.55% Makefile 1.21%

cpp-eventemitter's Introduction

cpp-EventEmitter

Attach lightweight C++11 event emitting and handling capabilities to your existing C++ classes.

  • Compatible with GCC 4.7 and newer, Visual Studio 2013 (tested with RC) and Clang++ (with some multi-threading issues)
  • Single header file that you can copy to your codebase
  • Attach event handlers with lambda functions and construct very readable, elegant and concise code.
  • Define new emitters with a DefineEventEmitter macro to use methods such as emitChatMessage, onChatMessage or use EventEmitter<Args> template to define an event emitting member with methods on, trigger.
  • Leak-safe, uses shared pointers all over the place.
  • Different classes for different uses.

EventEmitter class

  • Events are immediately called upon trigger.
  • sizeof(void*) overhead for non-initialized emitter and 3 * sizeof(void*) per each attached handler.
  • Lightweight.

DeferredEventEmitter class

  • Events are cached upon trigger and run when called runDeferred() or runAllDeferred(). Useful when a different thread is a producer of events but you want the handlers to run in another thread.
  • Thread safe, mutex protected methods.

ThreadedEventEmitter class

  • Base EventEmitter functionality and DeferredEventEmitter compiled, the latter under defer instead of trigger.
  • Utilities for waiting for events, getting future results as std::future, adding async handlers and general thread safety.

EventDispatcher

  • Similiar to EventEmitter but dispatch events based on first argument, for example std::string.

cpp-eventemitter's People

Contributors

rush avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

qix- papsnoek

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.