Skip to content

C++11 object to execute functions on a separate thread, using a low level, custom built lock-free double buffered queue

License

Notifications You must be signed in to change notification settings

therselman/CommandQueue

Repository files navigation

CommandQueue

A C++11 header-only object to execute functions on a separate thread. Featuring a unique custom built low level, lock-free double buffered queue. Executes the queue with a specially designed protocol, dedicated to high speed function calls in just 6 CPU instructions; lea,call,mov,add,cmp,jb

#include "CommandQueue.hpp" CommandQueue commandQ; // Creates a single thread, ready and waiting for commands void cmdPrintf( const char* str ){printf( str )} int main(){commandQ( cmdPrintf, "Hello " ); // Method 1 - functor commandQ.execute( cmdPrintf, "World\n" ); // Method 2 - function commandQ( cmdPrintf, "Chained" )( cmdPrintf, " - link 1" )( cmdPrintf, " - link 2\n" ); // Method 3 commandQ.join(); // The thread doesn't actually terminate here, you can issue more commands! return 0} 

About

C++11 object to execute functions on a separate thread, using a low level, custom built lock-free double buffered queue

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages