posix/coil/Task.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
19 #include <coil/Task.h>
20 
21 namespace coil
22 {
23 
32  : m_count(0)
33  {
34  ::pthread_attr_init(&m_attr);
35  }
36 
45  {
46  m_count = 0;
47  }
48 
56  int Task::open(void* args)
57  {
58  return 0;
59  }
60 
68  int Task::close(unsigned long flags)
69  {
70  return 0;
71  }
72 
80  int Task::svc()
81  {
82  return 0;
83  }
84 
93  {
94  if (m_count == 0)
95  {
96  ::pthread_create(&m_thread,
97  &m_attr,
98  (void* (*)(void*))Task::svc_run,
99  this);
100  ++m_count;
101  };
102  }
103 
111  int Task::wait(void)
112  {
113  if (m_count > 0)
114  {
115  void* retval;
116  ::pthread_join(m_thread, &retval);
117  }
118  return 0;
119  }
120 
128  int Task::suspend(void)
129  {
130  return 0;
131  }
132 
140  int Task::resume(void)
141  {
142  return 0;
143  }
144 
152  void Task::reset()
153  {
154  m_count = 0;
155  }
156 
165  {
166  reset();
167  }
168 
176  void* Task::svc_run(void* args)
177  {
178  Task* t = (coil::Task*)args;
179  int status;
180  status = t->svc();
181  t->finalize();
182  return 0;
183  }
184 };
185 
186 
virtual int svc()
Execute thread.
virtual ~Task()
Destructor.
virtual int wait(void)
Waiting for the thread terminate.
virtual int suspend(void)
Suspending the task.
virtual int resume(void)
Resuming the suspended task.
pthread_attr_t m_attr
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 Mon Feb 28 2022 23:00:45