cgma
CubitConcurrent Class Reference

Api for concurrency. More...

#include <CubitConcurrentApi.h>

Inheritance diagram for CubitConcurrent:
CubitQtConcurrent

List of all members.

Classes

struct  ClassFunctionTask
struct  ClassFunctionTaskArg1
struct  ClassFunctionTaskArg2
class  Mutex
struct  MutexLocker
struct  Task
struct  TaskGroup
class  ThreadLocalStorage
class  ThreadLocalStorageInterface

Public Member Functions

 CubitConcurrent ()
virtual ~CubitConcurrent ()
virtual Mutexcreate_mutex ()
virtual void destroy_mutex (Mutex *m)
virtual
ThreadLocalStorageInterface
create_local_storage (void(*cleanup_function)(void *))=0
virtual void destroy_local_storage (ThreadLocalStorageInterface *s)=0
template<typename X >
Taskcreate_and_schedule (X &x, void(X::*fun)())
template<typename X , typename Param1 , typename Arg1 >
Taskcreate_and_schedule (X &x, void(X::*fun)(Param1), const Arg1 &arg1)
template<typename X , typename Param1 , typename Arg1 >
Taskcreate_and_schedule (X &x, void(X::*fun)(Param1), Arg1 &arg1)
template<typename X , typename Param1 , typename Param2 , typename Arg1 , typename Arg2 >
Taskcreate_and_schedule (X &x, void(X::*fun)(Param1, Param2), const Arg1 &arg1, const Arg2 &arg2)
template<typename X , typename Param1 , typename Param2 , typename Arg1 , typename Arg2 >
Taskcreate_and_schedule (X &x, void(X::*fun)(Param1, Param2), Arg1 &arg1, const Arg2 &arg2)
template<typename X , typename Param1 , typename Param2 , typename Arg1 , typename Arg2 >
Taskcreate_and_schedule (X &x, void(X::*fun)(Param1, Param2), const Arg1 &arg1, Arg2 &arg2)
template<typename X , typename Param1 , typename Param2 , typename Arg1 , typename Arg2 >
Taskcreate_and_schedule (X &x, void(X::*fun)(Param1, Param2), Arg1 &arg1, Arg2 &arg2)
template<typename X , typename Param , typename Sequence >
TaskGroupcreate_and_schedule_group (X &x, void(X::*fun)(Param), Sequence &seq)
template<typename X , typename Param , typename Sequence >
TaskGroupcreate_and_schedule_group (X &x, void(X::*fun)(Param), const Sequence &seq)
template<typename X , typename Param1 , typename Param2 , typename Sequence1 , typename Sequence2 >
TaskGroupcreate_and_schedule_group (X &x, void(X::*fun)(Param1, Param2), Sequence1 &seq1, Sequence2 &seq2)
template<typename X , typename Param1 , typename Param2 , typename Sequence1 , typename Sequence2 >
TaskGroupcreate_and_schedule_group (X &x, void(X::*fun)(Param1, Param2), const Sequence1 &seq1, Sequence2 &seq2)
template<typename X , typename Param1 , typename Param2 , typename Sequence1 , typename Sequence2 >
TaskGroupcreate_and_schedule_group (X &x, void(X::*fun)(Param1, Param2), Sequence1 &seq1, const Sequence2 &seq2)
template<typename X , typename Param1 , typename Param2 , typename Sequence1 , typename Sequence2 >
TaskGroupcreate_and_schedule_group (X &x, void(X::*fun)(Param1, Param2), const Sequence1 &seq1, const Sequence2 &seq2)
void delete_group (TaskGroup *tg)
virtual void wait (Task *task)=0
virtual void idle_wait (Task *task)
virtual void wait (const std::vector< Task * > &task)=0
virtual void wait_for_any (const std::vector< Task * > &tasks, std::vector< Task * > &finished_tasks)=0
virtual bool is_completed (Task *task)=0
virtual bool is_running (Task *task)=0
virtual void wait (TaskGroup *task_group)=0
virtual bool is_completed (TaskGroup *task_group)=0
virtual bool is_running (TaskGroup *task_group)=0
virtual void cancel (TaskGroup *task_group)=0
const char * get_base_type () const

Static Public Member Functions

static CubitConcurrentinstance ()

Protected Member Functions

virtual void schedule (Task *task)=0
virtual void schedule (TaskGroup *task_group)=0
template<typename X , typename Param1 , typename Arg1 >
Taskcreate_task1 (X &x, void(X::*fun)(Param1), Arg1 arg1)
template<typename X , typename Param1 , typename Param2 , typename Arg1 , typename Arg2 >
Taskcreate_task2 (X &x, void(X::*fun)(Param1, Param2), Arg1 arg1, Arg2 arg2)
template<typename X , typename Param , typename Sequence , typename Iterator >
TaskGroupcreate_taskgroup1 (X &x, void(X::*fun)(Param), Sequence &seq)
template<typename X , typename Param1 , typename Param2 , typename Sequence1 , typename Sequence2 , typename Iterator1 , typename Iterator2 >
TaskGroupcreate_taskgroup2 (X &x, void(X::*fun)(Param1, Param2), Sequence1 &seq1, Sequence2 &seq2)

Static Protected Attributes

static CubitConcurrentmInstance = 0
 Stores the global instance.

Detailed Description

Api for concurrency.

Definition at line 14 of file CubitConcurrentApi.h.


Constructor & Destructor Documentation

Definition at line 65 of file CubitConcurrentApi.cpp.

{
}

Definition at line 69 of file CubitConcurrentApi.cpp.

{
}

Member Function Documentation

virtual void CubitConcurrent::cancel ( TaskGroup task_group) [pure virtual]

Implemented in CubitQtConcurrent.

template<typename X >
Task* CubitConcurrent::create_and_schedule ( X x,
void(X::*)()  fun 
) [inline]

Definition at line 152 of file CubitConcurrentApi.h.

  {
    Task* t = new ClassFunctionTask<X>(x, fun);
    this->schedule(t);
    return t;
  };
template<typename X , typename Param1 , typename Arg1 >
Task* CubitConcurrent::create_and_schedule ( X x,
void(X::*)(Param1)  fun,
const Arg1 &  arg1 
) [inline]

Definition at line 177 of file CubitConcurrentApi.h.

  {
    return create_task1<X,Param1,const Arg1&>(x,fun,arg1);
  };
template<typename X , typename Param1 , typename Arg1 >
Task* CubitConcurrent::create_and_schedule ( X x,
void(X::*)(Param1)  fun,
Arg1 &  arg1 
) [inline]

Definition at line 184 of file CubitConcurrentApi.h.

  {
    return create_task1<X,Param1,Arg1&>(x,fun,arg1);
  };
template<typename X , typename Param1 , typename Param2 , typename Arg1 , typename Arg2 >
Task* CubitConcurrent::create_and_schedule ( X x,
void(X::*)(Param1, Param2)  fun,
const Arg1 &  arg1,
const Arg2 &  arg2 
) [inline]

Definition at line 209 of file CubitConcurrentApi.h.

  {
    return create_task2<X,Param1,Param2, const Arg1&,const Arg2&>(x,fun,arg1, arg2);
  };
template<typename X , typename Param1 , typename Param2 , typename Arg1 , typename Arg2 >
Task* CubitConcurrent::create_and_schedule ( X x,
void(X::*)(Param1, Param2)  fun,
Arg1 &  arg1,
const Arg2 &  arg2 
) [inline]

Definition at line 215 of file CubitConcurrentApi.h.

  {
    return create_task2<X,Param1,Param2,Arg1&, const Arg2&>(x,fun,arg1, arg2);
  };
template<typename X , typename Param1 , typename Param2 , typename Arg1 , typename Arg2 >
Task* CubitConcurrent::create_and_schedule ( X x,
void(X::*)(Param1, Param2)  fun,
const Arg1 &  arg1,
Arg2 &  arg2 
) [inline]

Definition at line 221 of file CubitConcurrentApi.h.

  {
    return create_task2<X,Param1,Param2,const Arg1&,Arg2&>(x,fun,arg1, arg2);
  };
template<typename X , typename Param1 , typename Param2 , typename Arg1 , typename Arg2 >
Task* CubitConcurrent::create_and_schedule ( X x,
void(X::*)(Param1, Param2)  fun,
Arg1 &  arg1,
Arg2 &  arg2 
) [inline]

Definition at line 227 of file CubitConcurrentApi.h.

  {
    return create_task2<X,Param1,Param2,Arg1&,Arg2&>(x,fun,arg1, arg2);
  };
template<typename X , typename Param , typename Sequence >
TaskGroup* CubitConcurrent::create_and_schedule_group ( X x,
void(X::*)(Param)  fun,
Sequence &  seq 
) [inline]

Definition at line 251 of file CubitConcurrentApi.h.

  {
    return create_taskgroup1<X, Param, Sequence, typename Sequence::iterator>(x, fun, seq);
  };
template<typename X , typename Param , typename Sequence >
TaskGroup* CubitConcurrent::create_and_schedule_group ( X x,
void(X::*)(Param)  fun,
const Sequence &  seq 
) [inline]

Definition at line 257 of file CubitConcurrentApi.h.

  {
    return create_taskgroup1<X, Param, const Sequence, typename Sequence::const_iterator>(x, fun, seq);
  };
template<typename X , typename Param1 , typename Param2 , typename Sequence1 , typename Sequence2 >
TaskGroup* CubitConcurrent::create_and_schedule_group ( X x,
void(X::*)(Param1, Param2)  fun,
Sequence1 &  seq1,
Sequence2 &  seq2 
) [inline]

Definition at line 283 of file CubitConcurrentApi.h.

  {
    return create_taskgroup2<X, Param1, Param2, Sequence1, Sequence2, typename Sequence1::iterator, typename Sequence2::iterator>(x, fun, seq1, seq2);
  };
template<typename X , typename Param1 , typename Param2 , typename Sequence1 , typename Sequence2 >
TaskGroup* CubitConcurrent::create_and_schedule_group ( X x,
void(X::*)(Param1, Param2)  fun,
const Sequence1 &  seq1,
Sequence2 &  seq2 
) [inline]

Definition at line 289 of file CubitConcurrentApi.h.

  {
    return create_taskgroup2<X, Param1, Param2, const Sequence1, Sequence2, typename Sequence1::const_iterator, typename Sequence2::iterator>(x, fun, seq1, seq2);
  };
template<typename X , typename Param1 , typename Param2 , typename Sequence1 , typename Sequence2 >
TaskGroup* CubitConcurrent::create_and_schedule_group ( X x,
void(X::*)(Param1, Param2)  fun,
Sequence1 &  seq1,
const Sequence2 &  seq2 
) [inline]

Definition at line 295 of file CubitConcurrentApi.h.

  {
    return create_taskgroup2<X, Param1, Param2, Sequence1, const Sequence2, typename Sequence1::iterator, typename Sequence2::const_iterator>(x, fun, seq1, seq2);
  };
template<typename X , typename Param1 , typename Param2 , typename Sequence1 , typename Sequence2 >
TaskGroup* CubitConcurrent::create_and_schedule_group ( X x,
void(X::*)(Param1, Param2)  fun,
const Sequence1 &  seq1,
const Sequence2 &  seq2 
) [inline]

Definition at line 301 of file CubitConcurrentApi.h.

  {
    return create_taskgroup2<X, Param1, Param2, const Sequence1, const Sequence2, typename Sequence1::const_iterator, typename Sequence2::const_iterator>(x, fun, seq1, seq2);
  };
virtual ThreadLocalStorageInterface* CubitConcurrent::create_local_storage ( void(*)(void *)  cleanup_function) [pure virtual]

Implemented in CubitQtConcurrent.

Definition at line 78 of file CubitConcurrentApi.cpp.

{
  return new RealMutex;
}
template<typename X , typename Param1 , typename Arg1 >
Task* CubitConcurrent::create_task1 ( X x,
void(X::*)(Param1)  fun,
Arg1  arg1 
) [inline, protected]

Definition at line 425 of file CubitConcurrentApi.h.

  {
    Task* t = new ClassFunctionTaskArg1<X, Param1>(x, fun, arg1);
    this->schedule(t);
    return t;
  }
template<typename X , typename Param1 , typename Param2 , typename Arg1 , typename Arg2 >
Task* CubitConcurrent::create_task2 ( X x,
void(X::*)(Param1, Param2)  fun,
Arg1  arg1,
Arg2  arg2 
) [inline, protected]

Definition at line 432 of file CubitConcurrentApi.h.

  {
    Task* t = new ClassFunctionTaskArg2<X, Param1, Param2>(x, fun, arg1, arg2);
    this->schedule(t);
    return t;
  }
template<typename X , typename Param , typename Sequence , typename Iterator >
TaskGroup* CubitConcurrent::create_taskgroup1 ( X x,
void(X::*)(Param)  fun,
Sequence &  seq 
) [inline, protected]

Definition at line 440 of file CubitConcurrentApi.h.

  {
    TaskGroup* tg = new TaskGroup;
    Iterator iter;
    for(iter = seq.begin(); iter != seq.end(); ++iter)
      {
      Task* t = new ClassFunctionTaskArg1<X, Param>(x, fun, *iter);
      tg->tasks.push_back(t);
      }
    this->schedule(tg);
    return tg;
  }
template<typename X , typename Param1 , typename Param2 , typename Sequence1 , typename Sequence2 , typename Iterator1 , typename Iterator2 >
TaskGroup* CubitConcurrent::create_taskgroup2 ( X x,
void(X::*)(Param1, Param2)  fun,
Sequence1 &  seq1,
Sequence2 &  seq2 
) [inline, protected]

Definition at line 454 of file CubitConcurrentApi.h.

  {
    if(seq1.size() != seq2.size())
      return NULL;

    TaskGroup* tg = new TaskGroup;
    Iterator1 iter1;
    Iterator2 iter2;
    for(iter1 = seq1.begin(), iter2 = seq2.begin(); iter1 != seq1.end(); ++iter1, ++iter2)
      {
      Task* t = new ClassFunctionTaskArg2<X, Param1, Param2>(x, fun, *iter1, *iter2);
      tg->tasks.push_back(t);
      }
    this->schedule(tg);
    return tg;
  }
void CubitConcurrent::delete_group ( TaskGroup tg) [inline]

Definition at line 307 of file CubitConcurrentApi.h.

    {
    for(size_t i=0; i<tg->tasks.size(); i++)
      {
      delete tg->tasks[i];
      }
    delete tg;
    }

Implemented in CubitQtConcurrent.

Definition at line 83 of file CubitConcurrentApi.cpp.

{
  delete m;
}
const char * CubitConcurrent::get_base_type ( ) const

Definition at line 73 of file CubitConcurrentApi.cpp.

{ 
    return "ConcurrentApi";
}
virtual void CubitConcurrent::idle_wait ( Task task) [inline, virtual]

Reimplemented in CubitQtConcurrent.

Definition at line 324 of file CubitConcurrentApi.h.

  {
    wait(task);
  }
static CubitConcurrent* CubitConcurrent::instance ( void  ) [inline, static]

Gets the global Concurrent instance.

Returns:
A Pointer to the global Concurrent instance.

Definition at line 23 of file CubitConcurrentApi.h.

{return mInstance;}
virtual bool CubitConcurrent::is_completed ( Task task) [pure virtual]

Implemented in CubitQtConcurrent.

virtual bool CubitConcurrent::is_completed ( TaskGroup task_group) [pure virtual]

Implemented in CubitQtConcurrent.

virtual bool CubitConcurrent::is_running ( Task task) [pure virtual]

Implemented in CubitQtConcurrent.

virtual bool CubitConcurrent::is_running ( TaskGroup task_group) [pure virtual]

Implemented in CubitQtConcurrent.

virtual void CubitConcurrent::schedule ( Task task) [protected, pure virtual]

Implemented in CubitQtConcurrent.

virtual void CubitConcurrent::schedule ( TaskGroup task_group) [protected, pure virtual]

Implemented in CubitQtConcurrent.

virtual void CubitConcurrent::wait ( Task task) [pure virtual]

Implemented in CubitQtConcurrent.

virtual void CubitConcurrent::wait ( const std::vector< Task * > &  task) [pure virtual]

Implemented in CubitQtConcurrent.

virtual void CubitConcurrent::wait ( TaskGroup task_group) [pure virtual]

Implemented in CubitQtConcurrent.

virtual void CubitConcurrent::wait_for_any ( const std::vector< Task * > &  tasks,
std::vector< Task * > &  finished_tasks 
) [pure virtual]

Implemented in CubitQtConcurrent.


Member Data Documentation

CubitConcurrent * CubitConcurrent::mInstance = 0 [static, protected]

Stores the global instance.

Definition at line 357 of file CubitConcurrentApi.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines