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   }
00035 
00043   Task::~Task()
00044   {
00045     m_count = 0;
00046   }
00047 
00055   int Task::open(void* args)
00056   {
00057     return 0;
00058   }
00059 
00067   int Task::close(unsigned long flags)
00068   {
00069     return 0;
00070   }
00071 
00079   int Task::svc()
00080   {
00081     return 0;
00082   }
00083 
00091   void Task::activate()
00092   {
00093     if (m_count == 0)
00094       {
00095                   m_thread =
00096                           (HANDLE)::_beginthreadex(NULL, // security
00097                           0, //stuck size
00098                           Task::svc_run, // func
00099                           (void*)this, // argument
00100                           0, // flag (0 or CREATE_SUSPEND)
00101                           NULL); //thread descripter
00102                   ++m_count;
00103       };
00104   }
00105 
00113   int Task::wait(void)
00114   {
00115     if (m_count > 0)
00116       {
00117         DWORD retval;
00118         retval = ::WaitForSingleObject(m_thread, INFINITE);
00119       }
00120     return 0;
00121   }
00122 
00130   int Task::suspend(void)
00131   {
00132     return 0;
00133   }
00134 
00142   int Task::resume(void)
00143   {
00144     return 0;
00145   }
00146 
00154   void Task::reset()
00155   {
00156     m_count = 0;
00157   }
00158 
00166   void Task::finalize()
00167   {
00168     reset();
00169   }
00170  
00178   unsigned int WINAPI Task::svc_run(void* args)
00179   {
00180     Task* t = (coil::Task*)args;
00181     int status;
00182     status = t->svc();
00183     t->finalize();
00184     return 0;
00185   }
00186 };
00187 
00188 


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Aug 27 2015 14:16:39