threadmm::basic_thread< Backend > Class Template Reference
[Interface classes]

#include <threadmm/thread.hh>

List of all members.


Detailed Description

template<template< class > class Backend = ::threadmm::posix::thread>
class threadmm::basic_thread< Backend >

Basic thread class.

Parameters:
Backend Implementation details.
User must derive from this class to make threads. For example
#ifndef THREADMM_thread
#include <threadmm/thread.hh>
#endif
using namespace std;

namespace example 
{
  class simple : public threadmm::thread
  {
  private: 
    const char* _c;
  public:
    simple(const char* c) : _c(c) {}
    virtual ~simple() {}
    void* operator()()  { 
      cerr << "Starting process " << _c << endl;
      for (int i = 0; i < 10000; i++) cout << _c << flush;
        // write (1, _c, 1);
      return NULL;
    }
  };

  class create_join
  {
  private:
    simple a;
    simple b;
  public:
    create_join() : a("a"), b("b") {}
    int run() { 
      try {
        a.run();
        b.run();
        a.join();
        b.join();
      }
      catch (exception& e) {
        cerr << e.what() << endl;
        return 1;
      }
      cout << endl;
      return 0; 
    }
  };
}

//_______________________________________________________________________
int main(int argc, char** argv)
{
  if (!example::options(argc, argv)) return 0;

  example::create_join exa;
  return exa.run();
}
See also:
threadmm::posix::thread

threadmm::cthreads::thread


Public Types

typedef Backend< basic_thread<
Backend > > 
backend_type

Public Member Functions

virtual void on_exception (std::exception &)
virtual void on_exception ()
 basic_thread (int flags=joinable|deferred|inherit|system, int policy=regular, int priority=0, int gsize=-1, void *address=0, size_t ssize=0)
bool operator== (const basic_thread &other)
virtual void * operator() ()
void run ()

Friends

class Backend


Member Typedef Documentation

template<template< class > class Backend = ::threadmm::posix::thread>
typedef Backend<basic_thread<Backend> > threadmm::basic_thread< Backend >::backend_type
 


Constructor & Destructor Documentation

template<template< class > class Backend = ::threadmm::posix::thread>
threadmm::basic_thread< Backend >::basic_thread int  flags = joinable|deferred|inherit|system,
int  policy = regular,
int  priority = 0,
int  gsize = -1,
void *  address = 0,
size_t  ssize = 0
[inline]
 


Member Function Documentation

template<template< class > class Backend = ::threadmm::posix::thread>
virtual void threadmm::basic_thread< Backend >::on_exception  )  [inline, virtual]
 

template<template< class > class Backend = ::threadmm::posix::thread>
virtual void threadmm::basic_thread< Backend >::on_exception std::exception &   )  [inline, virtual]
 

template<template< class > class Backend = ::threadmm::posix::thread>
virtual void* threadmm::basic_thread< Backend >::operator()  )  [inline, virtual]
 

template<template< class > class Backend = ::threadmm::posix::thread>
bool threadmm::basic_thread< Backend >::operator== const basic_thread< Backend > &  other  )  [inline]
 

template<template< class > class Backend = ::threadmm::posix::thread>
void threadmm::basic_thread< Backend >::run  )  [inline]
 


Friends And Related Function Documentation

template<template< class > class Backend = ::threadmm::posix::thread>
friend class Backend [friend]
 

Private constructor used by backend.


The documentation for this class was generated from the following file:
Top of page
Last update Tue Nov 9 12:40:51 2004
Christian Holm
Created by DoxyGen 1.3.9.1