Xmipp  v3.23.11-Nereus
Public Member Functions | List of all members
Thread Class Referenceabstract

#include <xmipp_threads.h>

Inheritance diagram for Thread:
Inheritance graph
[legend]

Public Member Functions

 Thread ()
 
virtual ~Thread ()
 
virtual void run ()=0
 
void start ()
 

Detailed Description

Class wrapping around the pthreads. This class will ease the way to launch threads with a more object oriented, approach.

Definition at line 192 of file xmipp_threads.h.

Constructor & Destructor Documentation

◆ Thread()

Thread::Thread ( )

Default constructor. This constructor just initialize the pthread_mutex_t structure with its defaults values, just like static initialization with PTHREAD_MUTEX_INITIALIZER

Definition at line 126 of file xmipp_threads.cpp.

127 {
128 }

◆ ~Thread()

Thread::~Thread ( )
virtual

Destructor.

Definition at line 130 of file xmipp_threads.cpp.

131 {
132  pthread_join(thId, NULL);
133 }

Member Function Documentation

◆ run()

virtual void Thread::run ( )
pure virtual

This function should be implemented in subclasses and will be the main threads working function.

Implemented in FeaturesThread.

◆ start()

void Thread::start ( )

This function should not be re-implemented in sub-classes. This is the function to be called to start the run() in a separated thread.

Definition at line 135 of file xmipp_threads.cpp.

136 {
137  int result = pthread_create(&thId, NULL, _singleThreadMain, (void*)this);
138 
139  if (result != 0)
140  {
141  std::cerr << "Thread: can't start thread." << std::endl;
142  exit(1);
143  }
144 }
void * _singleThreadMain(void *data)

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