lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
Pds::Task Class Reference

Thread that runs Routine jobs from a queue in order (TaskMainLoop). More...

#include <Task.hh>

Public Types

enum  MakeThisATaskFlag { MakeThisATask }
 Tag type that selects the constructor which wraps the calling thread instead of creating one. More...
 

Public Member Functions

 Task (const TaskObject &)
 Copy the TaskObject parameters, create the job queue and pending semaphore and start the thread with pthread_create() (stack size and priority from the parameters); a creation error is ignored.
 
 Task (const Task &)
 Share the thread, queue, semaphore and parameters of aTask and increment the shared reference count.
 
 Task (MakeThisATaskFlag)
 Wrap the calling thread: create default TaskObject parameters (thread ID of the caller), a job queue and a pending semaphore, without starting a thread.
 
void operator= (const Task &)
 Share the thread, queue, semaphore and parameters of aTask; unlike the copy constructor, the reference count is not incremented.
 
const TaskObject & parameters () const
 Return the TaskObject parameters.
 
void call (Routine *)
 Insert routine at the tail of the job queue and give the pending semaphore if the queue was empty.
 
void destroy ()
 Decrement the shared reference count; if others remain, delete this handle, and if it reaches 0, queue a TaskDelete so that the thread deletes everything and exits.
 
void mainLoop ()
 Run TaskMainLoop() on the calling thread (used with the MakeThisATask constructor); never returns.
 
void signal (int signal)
 Send signal to the task thread with pthread_kill().
 
bool is_self () const
 Return true if the calling thread is the task thread.
 

Friends

class TaskDelete
 Lets TaskDelete call the private deleteTask().
 
void * TaskMainLoop (void *)
 Lets TaskMainLoop() reach the private job queue and semaphore.
 

Detailed Description

Thread that runs Routine jobs from a queue in order (TaskMainLoop).

Copies share the same thread, queue and reference count.

Member Enumeration Documentation

◆ MakeThisATaskFlag

Tag type that selects the constructor which wraps the calling thread instead of creating one.

Enumerator
MakeThisATask 

The only value of the tag.

Constructor & Destructor Documentation

◆ Task() [1/3]

Pds::Task::Task ( const TaskObject &  )

Copy the TaskObject parameters, create the job queue and pending semaphore and start the thread with pthread_create() (stack size and priority from the parameters); a creation error is ignored.

◆ Task() [2/3]

Pds::Task::Task ( const Task &  )

Share the thread, queue, semaphore and parameters of aTask and increment the shared reference count.

◆ Task() [3/3]

Pds::Task::Task ( MakeThisATaskFlag  )

Wrap the calling thread: create default TaskObject parameters (thread ID of the caller), a job queue and a pending semaphore, without starting a thread.

Member Function Documentation

◆ call()

void Pds::Task::call ( Routine *  )

Insert routine at the tail of the job queue and give the pending semaphore if the queue was empty.

◆ destroy()

void Pds::Task::destroy ( )

Decrement the shared reference count; if others remain, delete this handle, and if it reaches 0, queue a TaskDelete so that the thread deletes everything and exits.

◆ is_self()

bool Pds::Task::is_self ( ) const

Return true if the calling thread is the task thread.

◆ mainLoop()

void Pds::Task::mainLoop ( )

Run TaskMainLoop() on the calling thread (used with the MakeThisATask constructor); never returns.

◆ operator=()

void Pds::Task::operator= ( const Task &  )

Share the thread, queue, semaphore and parameters of aTask; unlike the copy constructor, the reference count is not incremented.

◆ parameters()

const TaskObject & Pds::Task::parameters ( ) const

Return the TaskObject parameters.

◆ signal()

void Pds::Task::signal ( int  signal)

Send signal to the task thread with pthread_kill().

Friends And Related Symbol Documentation

◆ TaskDelete

friend class TaskDelete
friend

Lets TaskDelete call the private deleteTask().

◆ TaskMainLoop

void * TaskMainLoop ( void *  )
friend

Lets TaskMainLoop() reach the private job queue and semaphore.

Never returns.


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