How to use signal to handle control in C++

Hi,

I'm a newbie in C++. It would be appreciated if some one could help on this. Sample code snip should be very helpful.

I have an existing client-server code for Linux. The client code contains two classes, A and B. B is a callback class. Both A and B run in the same thread. Function callOneServerFunc() returns before the server calls the callback function in class B.

The client code looks something like:

class A
{
public:
void callServer();
};

A::callServer()
{
B *callbackListener = new B(this);

//serverPtr below is a handle to the server. Once server completes its job, it uses the
//passed callbackListener to call back to B::itIsCalledBackFromServer().

serverPtr->callOneServerFunc(callbackListener);

//How can I wait here until the server calls back
//to B::itIsCalledBackFromServer()? I guess I need to
//use signal somehow but not sure exactly how.

//Do other things
}

class B
{
public:

//This function is called by the server once server
//completes its job
void itIsCalledBackFromServer();
{
//Do something here.
}

};

I guess I need to use signal to handle the desired control but don't know how exactly. Your help would be highly appreciated.

Thanks,
BJ
Last edited on
Topic archived. No new replies allowed.