0

Is it possible to use ACE threads in C++ for execution of different tasks?

e.g. suppose the user creates two threads named threadA and threadB. Once they finish their execution on certain functions, can we use the same thread threadA and threadB for some other operation?

If possible then how?

greybeard
  • 2,249
  • 8
  • 30
  • 66
VickyCool
  • 113
  • 1
  • 12

1 Answers1

0

what's the benefits? anyway, you can create your own class derive from ACE_Task

class myjob : public ACE_Task< ACE_MT_SYNCH >
{
    public:
      ......
    //derived from ACE_Task
    virtual int open( void *arg = NULL );
    //derived from ACE_Task
    virtual int svc();
}

than call

this->activate();

in open(); run your job in

int svc()
{
    while( _running )
       ....
}

you can pass messages warpped by ACE_Message_Block( myjob::putq( ACE_Message_Block *pmb, ACE_Time_Value &timeout) ) to myjob, than choose what to do.

  • I have a question when ACE_TASK doesn't have any activate function how can you call it in class derived from myjob class . The activate function is in ACE_TASK_BASE class which is derived from ACE_TASK . But myjob class and ACE_TASK_BASE doesn't have any direct relation ? – user3798283 Oct 14 '22 at 02:41