Archived

This forum has been archived. Please start a new discussion on GitHub.

Force callback to be handled in a particular thread

In a typical callback scenario where a client implements two functions f1() and f2() and a server implements g() such that f1() calls g() remotely and g() calls f2() remotely, the client thread from which the remote call g() is issued is different from the client thread that handles the call of f2().

Which solution do you suggest to ensure that the call of f2() is handled in the same thread which previously issued g(), i.e. while the thread waits for the result of g() the handling of f2() is asynchronously executed in the same thread context.

I am addressing a Win32 environment. The only solution there seems to be APC (asynchronous procedure call). However, for a userspace APC to succeed a thread must be in alertable state which does not seem to be the case for Ice. So my approach right now would be to try QueueUserAPCEx, i.e. something like POSIX signals for Win32.

Do you have other suggestions?
Thanks for your help.