ONPOSIX  2.0
Public Member Functions | Private Attributes | List of all members
SimpleThread Class Reference

Class for simple thread invocation. More...

#include <SimpleThread.hpp>

Inheritance diagram for SimpleThread:
Inheritance graph

Public Member Functions

  SimpleThread (void(*handler)(void *p), void *arg)
virtual  ~SimpleThread ()
void  run ()
  Method run on the new thread.
- Public Member Functions inherited from AbstractThread
  Constructor. Initialize the class attributes.
virtual  ~AbstractThread ()
  Destructor.
bool  start ()
  Starts execution of the thread by calling run().
bool  stop ()
  Stops the running thread.
  Blocks the calling thread until the thread is finished.
bool  sendSignal (int sig)
  Sends a signal to the thread.
bool  setSchedParam (int policy, int priority)
  Set scheduling policy and priority.
bool  getSchedParam (int *policy, int *priority)
  Get current scheduling policy and priority.

Private Attributes

void(*  handler_ )(void *p)
void *  arg_

Additional Inherited Members

- Static Public Member Functions inherited from AbstractThread
static bool  blockSignal (int sig)
  Masks a specific signal on this thread.
static bool  unblockSignal (int sig)
  Unmasks a signal previously masked.
static bool  setSignalHandler (int sig, void(*handler)(int))
  Set a handler for a specific signal.
- Static Protected Member Functions inherited from AbstractThread
static void  checkTermination ()
  Function to know if the thread has finished computation.
- Protected Attributes inherited from AbstractThread
pthread_t  handle_

Detailed Description

Class for simple thread invocation.

This class is useful for creating threads that do not return any value. For more complex cases (e.g., return value), create your own thread by inheriting from class AbstractThread.

Example of usage:

void myfunction (void* arg);
int main ()
{
int b;
SimpleThread t (myfunction, (void*) b);
t.start();
t.waitForTermination();
}

Definition at line 55 of file SimpleThread.hpp.

Constructor & Destructor Documentation

SimpleThread ( void(*)(void *p)  handler,
void *  arg 
)
inline

Definition at line 62 of file SimpleThread.hpp.

:
handler_(handler),
arg_(arg) {}
virtual ~SimpleThread ( )
inlinevirtual

Definition at line 65 of file SimpleThread.hpp.

{}

Member Function Documentation

void run ( )
inlinevirtual

Method run on the new thread.

This method is run on the new thread once start() is invoked.

Implements AbstractThread.

Definition at line 73 of file SimpleThread.hpp.

{
}

Member Data Documentation

void* arg_
private

Definition at line 58 of file SimpleThread.hpp.

void(* handler_)(void *p)
private

Definition at line 57 of file SimpleThread.hpp.


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

AltStyle によって変換されたページ (->オリジナル) /