![]() |
Scanframe Modular Application 0.1.0
|
Class which combines a thread class and closure template. More...
#include <ThreadClosure.h>


Public Member Functions | |
| ThreadClosure (const std::string &name="") | |
| Default constructor. | |
| ThreadClosure (const func_type &func, const std::string &name="") | |
| Thread run function assigment constructor. | |
Public Member Functions inherited from sf::Thread | |
| handle_type | start () |
| Starts a thread with default attributes which calls on its turn the overridden run(). | |
| handle_type | start (const Attributes &attr) |
| Starts a thread which calls on its turn the overridden function Run(). | |
| virtual void | terminate () |
| Can be overridden to signal the thread to terminate. | |
| void | terminateAndWait () |
| Same as calling Terminate() and thereafter calling WaitForExit() | |
| void | waitForExit () |
| Waits for the thread to exit. | |
| EStatus | getStatus () const |
| Returns the status. | |
| const char * | getStatusText (EStatus status=(EStatus) -1) const |
| Returns the status a string. | |
| int | getExitCode () const |
| Returns the exist value of the thread function. | |
| bool | isSelf () const |
| Returns true if the calling thread is this thread. | |
| id_type | getId () const |
| Returns the thread ID. Is currently in Linux the same as the handle. | |
| handle_type | getHandle () const |
| Returns the handle of this instance. | |
| operator handle_type () const | |
| Casting operator for THandle type. | |
| void | setName (const char *name) |
| Sets the name of the thread available in the debugger. The name is clipped to the first 15 characters only. | |
| std::string | getName () const |
| Gets the name of the thread available in the debugger. | |
| int | getPriority () const |
| Gets the current priority of this instance. | |
| bool | setPriority (int pri, int sp=Attributes::spScheduleOther) |
| Can pass an enumerate EPriority for simplicity. | |
| void | setTerminationTime (const TimeSpec &ts) |
| Sets the time needed for the thread to terminate. Default is one 100 ms. | |
| bool | shouldTerminate () const |
| Call by the thread itself to determine if it should terminate. Another thread then this one it too but has no effect. | |
| void | exit (int code) |
| Alternative to returning from then run() method. Called from within the thread that wants to exit early. It save-guarded from other threads calling it. | |
| void | setDebug (bool yn) |
| Enables debug logging. | |
| bool | sleep (const TimeSpec &ts, bool alertable=true) const |
| Makes the current thread sleep for the given amount time until a signal interrupts when alertable is true. | |
| Thread (const Thread &)=delete | |
| Copying constructor disabled and not implemented. | |
| const Thread & | operator= (const Thread &)=delete |
| Copy constructor not implemented. | |
| bool | isDebug () const |
| Gets the debug flag. | |
Public Member Functions inherited from sf::TClosure< int, Thread & > | |
| TClosure ()=default | |
| Default constructor. | |
| TClosure (const TClosure &c) | |
| Copy constructor. | |
| TClosure (const func_type &fn) | |
| Function assignment constructor. | |
| TClosure & | assign (const func_type &fn) |
| Function assignment method for static function. | |
| TClosure & | assign (ClassType *cls, MethodType mtd, BoundArgs... args) |
| Binds a non-static class member function to this instance. | |
| TClosure & | unassign () |
| Releases the bind function. | |
| TClosure & | operator= (const TClosure &c) |
| Closure assignment operator. | |
| TClosure & | operator= (const func_type &f) |
| Closure assignment operator. | |
| int | operator() (Args... args) const |
| Make the call to the member function. | |
| bool | isAssigned () const |
| Checks if the closure is valid for calling. | |
| operator bool () const | |
| Checks if the closure is valid for calling. | |
Protected Member Functions | |
| int | run () override |
Protected Member Functions inherited from sf::Thread | |
| Thread (const std::string &name) | |
| Protected constructor which demands to derive a class. | |
| Thread (bool) | |
| Wraps this class around the main thread of the application. The boolean bogus argument is to be different from the default constructor. | |
| virtual | ~Thread () |
| Virtual Destructor. | |
| virtual void | cleanup () |
| Function which can be overridden in a derived class. | |
| void | TerminationSignal () |
| Called to unblock system functions. | |
Protected Member Functions inherited from sf::TClosure< int, Thread & > | |
| int | call (Args... args) const |
| Makes the call to the member function. | |
Additional Inherited Members | |
Public Types inherited from sf::Thread | |
| enum | EStatus : int { tsInvalid = 0 , tsCreated , tsRunning , tsFinished , tsTerminated } |
| Thread states enumeration. More... | |
| enum | EPriority : int { tpIdle = -15 , tpLowest = -2 , tpBelowNormal = -1 , tpNormal = 0 , tpAboveNormal = 1 , tpHighest = 2 , tpTimeCritical = 15 } |
| Enumeration of thread priorities. More... | |
| typedef pthread_t | handle_type |
| Local declaration of the handle type. | |
| typedef pid_t | id_type |
| Local declaration of the thread id type. | |
Public Types inherited from sf::TClosure< int, Thread & > | |
| typedef std::function< int(Args...)> | func_type |
| Function type of the lambda or function. | |
Static Public Member Functions inherited from sf::Thread | |
| static int | getTerminationSignal () |
| Returns the thread termination signal. | |
| static bool | yieldToOther () |
| Yield control of the current thread. The name 'Yield()' is defined as a macro in MingW. | |
| static handle_type | getCurrentHandle () |
| Return the current thread handle. | |
| static id_type | getMainId () |
| Gets the main thread ID. | |
| static id_type | getCurrentId () |
| Gets the current thread ID. | |
| static Thread & | getCurrent () |
| Gets the sf::Thread instance reference of the current thread. | |
| static size_t | getCurrentStackSize () |
| Returns the current thread initial stack size. | |
Class which combines a thread class and closure template.
Allows linking of a lambda function to be called as a thread run function. Usage is like:
|
inline |
Default constructor.
|
inlineexplicit |
Thread run function assigment constructor.
| func | Function run by the thread. |
| name | Optional name of the thread executing. |
|
inlineoverrideprotectedvirtual |
Overrides run function and calls the closure assigned one.
Implements sf::Thread.