AsyncFw 1.2
Async Framework is c++ runtime with timers, poll notifiers, sockets, coroutines, etc.
 
Loading...
Searching...
No Matches
AsyncFw::Thread Class Reference

AsyncFw::Thread thread with sockets. More...

#include <AsyncFw/Thread>

Inheritance diagram for AsyncFw::Thread:
[legend]
Collaboration diagram for AsyncFw::Thread:
[legend]

Public Member Functions

 Thread (const std::string &="Thread")
 Constructs a thread.
 
- Public Member Functions inherited from AsyncFw::AbstractThread
template<typename M>
std::enable_if< std::is_void< typenamestd::invoke_result< M >::type >::value, bool >::type invokeMethod (M method, bool sync=false) const
 Runs a method in a managed thread.
 
template<typename M>
bool appendPollTask (int fd, PollEvents events, M method)
 Append poll task.
 
template<typename M>
int appendTimerTask (int timeout, M method)
 Append timer task.
 
virtual bool running () const
 Returns true if the managed thread is running.
 
virtual bool invokeTask (AbstractTask *) const
 Runs a task in a managed thread.
 
virtual int appendTimer (int, AbstractTask *)
 Append timer.
 
virtual bool modifyTimer (int, int)
 Modify timer.
 
virtual void removeTimer (int)
 Remove timer.
 
virtual bool appendPollDescriptor (int, PollEvents, AbstractPollTask *)
 Append poll descriptor.
 
virtual bool modifyPollDescriptor (int, PollEvents)
 Modify poll descriptor.
 
virtual void removePollDescriptor (int)
 Remove poll descriptor.
 
void start ()
 Create a managed thread and run exec().
 
void requestInterrupt ()
 Request the interruption of the thread.
 
bool interruptRequested () const
 Returns true if an interrupt is requested.
 
void waitInterrupted () const
 Wait for thread interrupted. This means that requestInterrupt() has been called and all queue tasks have completed.
 
void quit ()
 Tells the thread's exec() to exit.
 
void waitFinished () const
 Wait for the thread's exec() function finished.
 
int workLoad () const
 Returns the number of tasks in the queue, plus one if there are running task.
 
std::thread::id id () const
 Returns unique identifier of managed thread.
 
std::string name () const
 Returns name of managed thread.
 
LockGuard lockGuard () const
 Locks the managed thread and returns a LockGuard variable. The thread is unblocked after this variable is destroyed.
 

Static Public Member Functions

static ThreadcurrentThread ()
 Returns a pointer to the AsyncFw::Thread that manages the currently executing thread.
 
- Static Public Member Functions inherited from AsyncFw::AbstractThread
static AbstractThreadcurrentThread ()
 Returns a pointer to the AsyncFw::AbstractThread that manages the currently executing thread.
 
static AbstractThread::LockGuard threads (std::vector< AbstractThread * > **)
 Assigns a pointer to the list of all threads.
 

Public Attributes

FunctionConnectorProtected< Thread >::Connector<> started
 The Thread::started connector.
 
FunctionConnectorProtected< Thread >::Connector<> finished
 The Thread::finished connector.
 
FunctionConnectorProtected< Thread >::Connector<> destroing
 The Thread::destroing connector.
 

Protected Member Functions

void startedEvent () override
 Runs started()
 
void finishedEvent () override
 Runs finished()
 
- Protected Member Functions inherited from AsyncFw::AbstractThread
 AbstractThread (const std::string &)
 Constructs a thread.
 
void setId ()
 
void clearId ()
 
void exec ()
 Run manage loop.
 

Protected Attributes

std::vector< AbstractSocket * > sockets_
 

Friends

class ListenSocket
 
LogStreamoperator<< (LogStream &log, const Thread &t)
 

Additional Inherited Members

- Public Types inherited from AsyncFw::AbstractThread
enum  PollEvents : uint16_t {
  PollNo = 0 , PollIn = POLLIN_ , PollPri = POLLPRI_ , PollOut = POLLOUT_ ,
  PollErr = POLLERR_ , PollHup = POLLHUP_ , PollNval = POLLNVAL_
}
 
using LockGuard = std::lock_guard<std::mutex>
 The LockGuard type.
 
using AbstractTask = AbstractFunction<>
 The AbstractTask type.
 
using AbstractPollTask = AbstractFunction<AbstractThread::PollEvents>
 The AbstractPollTask type.
 

Detailed Description

AsyncFw::Thread thread with sockets.

Constructor & Destructor Documentation

◆ Thread()

Thread::Thread ( const std::string & name = "Thread")

Constructs a thread.

Parameters
namethread name
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ startedEvent()

void Thread::startedEvent ( )
overrideprotectedvirtual

Runs started()

Reimplemented from AsyncFw::AbstractThread.

Here is the call graph for this function:

◆ finishedEvent()

void Thread::finishedEvent ( )
overrideprotectedvirtual

Runs finished()

Reimplemented from AsyncFw::AbstractThread.

Here is the call graph for this function:

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