win32/coil/Task.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
19 #include <coil/Task.h>
20 
21 namespace coil
22 {
23 
31  Task::Task()
32  : m_count(0)
33  {
34  }
35 
43  Task::~Task()
44  {
45  m_count = 0;
46  }
47 
55  int Task::open(void* args)
56  {
57  return 0;
58  }
59 
67  int Task::close(unsigned long flags)
68  {
69  return 0;
70  }
71 
79  int Task::svc()
80  {
81  return 0;
82  }
83 
91  void Task::activate()
92  {
93  if (m_count == 0)
94  {
95  m_thread =
96  (HANDLE)::_beginthreadex(NULL, // security
97  0, //stuck size
98  Task::svc_run, // func
99  (void*)this, // argument
100  0, // flag (0 or CREATE_SUSPEND)
101  NULL); //thread descripter
102  ++m_count;
103  };
104  }
105 
113  int Task::wait(void)
114  {
115  if (m_count > 0)
116  {
117  DWORD retval;
118  retval = ::WaitForSingleObject(m_thread, INFINITE);
119  }
120  return 0;
121  }
122 
130  int Task::suspend(void)
131  {
132  return 0;
133  }
134 
142  int Task::resume(void)
143  {
144  return 0;
145  }
146 
154  void Task::reset()
155  {
156  m_count = 0;
157  }
158 
166  void Task::finalize()
167  {
168  reset();
169  }
170 
178  unsigned int WINAPI Task::svc_run(void* args)
179  {
180  Task* t = (coil::Task*)args;
181  int status;
182  status = t->svc();
183  t->finalize();
184  return 0;
185  }
186 };
187 
188 
virtual int svc()
Execute thread.
virtual ~Task()
Destructor.
#define WINAPI
Definition: RTC.h:74
virtual int wait(void)
Waiting for the thread terminate.
virtual int suspend(void)
Suspending the task.
virtual int resume(void)
Resuming the suspended task.
Task()
Constructor.
virtual void reset()
Reset of task count.
Task class.
static void * svc_run(void *args=0)
Start thread Execution.
virtual int open(void *args=0)
Task open.
virtual int close(unsigned long flags=0)
Task close.
pthread_t m_thread
virtual void activate()
Create a thread.
virtual void finalize()
Finalizing the task.
Common Object Interface Layer.


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Jun 6 2019 19:26:00