Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
sf::ThreadRelay Class Reference

Provides a way to stop executing a thread until the main thread enables the thread again. More...

#include <ThreadRelay.h>

Inheritance diagram for sf::ThreadRelay:
Collaboration diagram for sf::ThreadRelay:

Classes

class  Relay0
 Template for a method having 0 arguments. More...
 
class  Relay1
 Template for a method having 1 argument. More...
 
class  Relay2
 Template for a method having 2 arguments. More...
 
class  Relay3
 Template for a method having 3 arguments. More...
 
class  Relay4
 Template for a method having 4 arguments. More...
 
class  RelayBase
 Base class for the ThreadRelay::Relay0,1,2,3 templates for storing in a list. More...
 

Public Member Functions

 ThreadRelay ()
 Default constructor which also sets the thread execution ownership.
 
int checkForWork ()
 Called by main thread for instance. When a lock of this calling thread is requested.
 
void makeOwner (Thread::id_type threadId=0)
 The calling thread takes thread execution ownership when zero is passed or sets it when not zero.
 

Additional Inherited Members

- Protected Member Functions inherited from sf::Sync
 Sync ()=default
 Only multi inheritance is allowed to create this instance.
 
 Sync (const Sync &)
 Copy constructor does not copy the Mutex object, since the new object is not being used in any of its own member functions. This means that the new object must start in an unlocked state.
 
Syncoperator= (const Sync &)
 Does not copy the Mutex object, since the new object is not being used in any of its own member functions. This means that the new object must start in an unlocked state.
 

Detailed Description

Provides a way to stop executing a thread until the main thread enables the thread again.

std::unique_ptr<ThreadRelay> threadRelay;
class Worker
{
public:
int method1(int v1);
};
int Worker::method1(int v1)
{
int rv;
// Create the relay instance and use the bool operator to check if the code needs execution.
if (ThreadRelay::Relay1<Worker, decltype(&Worker::method1), int, int>
(*threadRelay, this, &Worker::method1, rv, v1))
{
return Thread::getCurrentId() + v1;
}
return rv;
}
Template for a method having 1 argument.
Definition ThreadRelay.h:129
static id_type getCurrentId()
Gets the current thread ID.

Constructor & Destructor Documentation

◆ ThreadRelay()

sf::ThreadRelay::ThreadRelay ( )

Default constructor which also sets the thread execution ownership.

Member Function Documentation

◆ checkForWork()

int sf::ThreadRelay::checkForWork ( )

Called by main thread for instance. When a lock of this calling thread is requested.

Returns
Amount of calls made.

◆ makeOwner()

void sf::ThreadRelay::makeOwner ( Thread::id_type  threadId = 0)

The calling thread takes thread execution ownership when zero is passed or sets it when not zero.


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