Cancel long-term RCF functions.

RCF support and general discussion.
Post Reply
cinsk
Posts: 5
Joined: Mon Mar 18, 2013 6:24 am

Cancel long-term RCF functions.

Post by cinsk »

Hi,

In our client/server designs, the server will expose a function process(), which may takes significant times.
In server-side, process() will allocated some external resources and doing time-consuming job, and release the resources,
and report the result back to the client.

One of our requirement is, there should be a way for a client to cancel the current process() call, and there should be
a way for a server to detect the client's cancel request, and release the allocated resources during current process() call.

I guess that, (according to the documentation) the client will register a "progress callback" and during at callback function,
client can throw an exception to cancel the current request. At this time, WHAT HAPPEN IN THE SERVER-SIDE call?

For example, assume the client call process(), and the server side is doing lots of stuffs in process(). If the client
throw an exception in the progress callback, what happen in the server-side code? Can the server-side detect the
client's cancelling request?

If my understanding or design is not appropriate, can you guide me for the better design for following requirements?

1. server need to provides a series of functions, which some of them may take long time to finish,
and it needs allocate/deallocate external resources (possibly from the 3rd party library module) for the processing.
(currently these functions uses RCF's session object to keep the internal states)

2. there should be a way for a client to cancel the current RCF call.

3. there should be a way for a server to detect the client's cancel request, and doing some deallocate/cleanup job.

Thanks,

jarl
Posts: 238
Joined: Mon Oct 03, 2011 4:53 am
Contact:

Re: Cancel long-term RCF functions.

Post by jarl »

From the client side, you can cancel the call in two ways:

1) If you are doing a synchronous RPC, you can put in a progress callback, and when the client wants to cancel, throw an exception from the progress callback. This will disconnect the client and the exception will be passed on to your own exception handlers.

2) If you are doing an asynchronous RPC, then just disconnect the client when you want to cancel.

Code: Select all

client.getClientStub().disconnect();
In both cases, your server side code can detect the disconnection, by calling RcfSession::isConnected() at regular intervals:

Code: Select all

RCF::RcfSession session = RCF::getCurrentSession();
bool isConnected = session.isConnected();
Kind Regards

Jarl Lindrud
Delta V Software
http://www.deltavsoft.com

Post Reply