cplusplus.com
C++ : Forum : UNIX/Linux Programming : How to use signal or something to handle
 
cplusplus.com
Information
Documentation
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs


question How to use signal or something to handle async function call?

BJT (2)
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
kbw (3827)
https://computing.llnl.gov/tutorials/pthreads/#ConVarSignal
Topic archived. No new replies allowed.