GithubHelp home page GithubHelp logo

filcuc / hope Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 0.0 177 KB

A simple pure C++11 event loop with signals and slots

License: GNU Lesser General Public License v3.0

CMake 5.70% C++ 92.71% C 1.58%
eventloop events loop qt5 signal slot hope cpp11

hope's Introduction

Hope

A simple pure C++11 event loop with signals and slots

Build Status Build status codecov

Notes

This project doesn't aim to become a general purpose library. It was done for fun and scratching my own itch. That said it can be useful for simple command line projects

How it looks?

#include <hope/application.h>
#include <hope/timer.h>

using namespace hope;

class HelloWorldPrinter : public Object {
public:
    void say_hello() {
        std::cout << "Hello World" << std::endl;
    }
};

int main(int argc, char* argv[])
{
    Application app;

    HelloWorldPrinter printer;

    Timer timer;
    timer.set_duration(std::chrono::seconds(1));
    timer.triggered().connect(&printer, &HelloWorldPrinter::say_hello);
    timer.triggered().connect(&app, &Application::quit);
    timer.start();

    return app.exec();
}

Building

The project require a working C++11 compiler

mkdir build
cd build 
cmake ..
cmake --build .

Installing

Follow the build steps and simply execute

sudo make install

hope's People

Contributors

filcuc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

hope's Issues

Research removal of queued signal events on disconnect

This would be cool and gives a lot more safety when deleting an Object from a different thread.
In fact if disconnecting ensure that there will be no more notification than we can safely delete the receiver. The hard part is that implementing this behaviour can cause deadlock

Fix Application + EventLoop + Thread relationships

Create a singleton (or thread local) struct for storing some information important for the current thread.
For example:

  • the current thread event loop (This should be set in the EventLoop::exec())
  • The Application should create a Thread and invoke its exec(). By not calling the Thread::start() it should not spawn a real thread

A Thread simply run an EventLoop and that's the reason why the Application class own a Thread

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.