Giter Club home page Giter Club logo

executor's Introduction

#Executor

Executor is a class that executes a function at specific times/intervals by using human language and a function pointer. This is helpful because sometimes you don't want to execute a function every time, and only once in a period. In most cases you will end with following solution:

int i = 0;
while(true)
{
	if(i == 1000)
	{
		.. do function call	
		i = 0;
	}
	i++;
}

Executor can help you to keep your code clean.

#Installation

Make sure you have a C++ compiler and cmake is installed.

##Linux / OSX

Make sure you are at the root of the Executor folder.

mkdir build && cd build && cmake .. && make

##Windows

  • install the cmake executable
  • open the cmake GUI and select the source and build directory
  • press the configure button
  • press the generate button
  • open the .sln file with Visual Studio (you can find it in the build directory)
  • build the project
  • execute the binary

#Usage

You can assign void functions, static void member functions and non-static void member functions to an executor.

Non-static member functions are a little bit complicater because you also need a reference to an existing object (this is something C++ does in the background for you, when calling member functions on an object).

// Executor can execute member functions of an object.
Executor<Foo> executeMember;
executeMember.setAction(new Foo(), &Foo::execute);
executeMember.setInterval("once in 10 executions");

// Executor can execute static member functions of an object.
Executor<> executeStaticMember;
executeStaticMember.setAction(&Foo::staticExecute);
executeStaticMember.setInterval("thrice in 10 executions");

// Executor can execute static functions.
Executor<> executeStatic;
executeStatic.setAction(&execute);
executeStatic.setInterval("2 times in 10 executions");

while (true)
{
	executeMember();
	executeStatic();
	executeStaticMember();
}

You can specify intervals by using human language:

// but you can also specify time intervals
execute.setInterval("four times a day");
execute.setInterval("once a day");
execute.setInterval("twice in 10 minutes");
execute.setInterval("thrice in 120 functions calls");

executor's People

Contributors

cedricve avatar

Watchers

James Cloos avatar Radoaslav Nedyalkov 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.