2

I need to emit a signal from child class to it's parent class when an asynchronous operation finished using boost signal,

For example my parent class

class A
{
    void doTask(){
      class B child;
      child.asynchTask();
    }

    void onFinished(){
      //invoke it when async task finished
    }
};

And the second class

class B
{
     void asynchTask(){
     //Async task start  here 

    }

 void asynchTaskFinished(){
      // Emit signal from here to invoke onFinished() of parent class

    }

};

How can I do it using boost signal, I already found some example and an SO post Complete example using Boost::Signals for C++ Eventing, but couldn't figure out how to implement in this case.

Any help will be appreciated.

Thanks Haris

Community
  • 1
  • 1
Haris
  • 13,645
  • 12
  • 90
  • 121
  • 1
    What is so special about this case? Define a signal in `class B`, and connect it with a slot bound to the instance of `class A`. By the way, if it's just a kind of completion handler, `asynchTask` can just accept an `std::function`, and invoke it on completion. Signals are more appropriate for multiple slots/notifications. – Igor R. Jun 10 '15 at 18:09
  • Thanks for the suggestion, I have solved the problem. – Haris Jun 11 '15 at 03:39

0 Answers0