Task.cpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00019 #include <coil/Task.h>
00020 
00021 namespace coil
00022 {
00023 
00031   Task::Task()
00032     : m_count(0)
00033   {
00034     ::pthread_attr_init(&m_attr);
00035   }
00036 
00044   Task::~Task()
00045   {
00046     m_count = 0;
00047   }
00048 
00056   int Task::open(void* args)
00057   {
00058     return 0;
00059   }
00060 
00068   int Task::close(unsigned long flags)
00069   {
00070     return 0;
00071   }
00072 
00080   int Task::svc()
00081   {
00082     return 0;
00083   }
00084 
00092   void Task::activate()
00093   {
00094     if (m_count == 0)
00095       {
00096         ::pthread_create(&m_thread,
00097                          &m_attr,
00098                          (void* (*)(void*))Task::svc_run,
00099                          this);
00100         ++m_count;
00101       };
00102   }
00103 
00111   int Task::wait(void)
00112   {
00113     if (m_count > 0)
00114       {
00115         void* retval;
00116         ::pthread_join(m_thread, &retval);
00117       }
00118     return 0;
00119   }
00120 
00128   int Task::suspend(void)
00129   {
00130     return 0;
00131   }
00132 
00140   int Task::resume(void)
00141   {
00142     return 0;
00143   }
00144 
00152   void Task::reset()
00153   {
00154     m_count = 0;
00155   }
00156 
00164   void Task::finalize()
00165   {
00166     reset();
00167   }
00168 
00176   void* Task::svc_run(void* args)
00177   {
00178     Task* t = (coil::Task*)args;
00179     int status;
00180     status = t->svc();
00181     t->finalize();
00182     return 0;
00183   }
00184 };
00185 
00186 


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Sun Mar 26 2017 03:37:17