Public Member Functions | Static Public Member Functions

SCS::ScopedParallelExecutor Class Reference

Easy way to execute an infinite loop in a separate thread until the object goes out of scope. More...

#include <scopedparallelexecutor.h>

List of all members.

Public Member Functions

 ScopedParallelExecutor (boost::function< void()> run_function, long run_interval_ms)
 ~ScopedParallelExecutor ()
void setCallback (boost::function< void()> run_function)
void setRunInterval (long milliseconds)

Static Public Member Functions

static void delay (int seconds)

Detailed Description

Easy way to execute an infinite loop in a separate thread until the object goes out of scope.

This class executes an inifinte loop and calls the provided in every cycle. This all takes place in a separate thread. The processing is stopped gracefully and the thread joined when the instance of this class goes out of scope.

Author:
(c) 2009,2010 by Philipp Münzel
Version:
1.3

Constructor & Destructor Documentation

SCS::ScopedParallelExecutor::ScopedParallelExecutor ( boost::function< void()>  run_function,
long  run_interval_ms 
)
Parameters:
run_functionFunction to be called in every loop cycle
run_interval_msSleep time between function calls in milliseconds
SCS::ScopedParallelExecutor::~ScopedParallelExecutor ( )

Waits for next function call and breaks main loop after it, then joins the thread.


Member Function Documentation

static void SCS::ScopedParallelExecutor::delay ( int  seconds) [static]

Platfrom-independant sleep function

Parameters:
seconds
void SCS::ScopedParallelExecutor::setCallback ( boost::function< void()>  run_function)
Parameters:
run_functionFunction to be called in every cycle. Replaces the old function.
void SCS::ScopedParallelExecutor::setRunInterval ( long  milliseconds)
Parameters:
millisecondsSleep time between function calls in milliseconds

The documentation for this class was generated from the following file: