From simon.urbanek at r-project.org  Tue Jul 20 20:45:06 2010
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Tue, 20 Jul 2010 14:45:06 -0400
Subject: [Rd] Non-blocking Eval
In-Reply-To: <COL117-W30C37D77057267045E331EC0A00@phx.gbl>
References: <COL117-W11775CC4DBBCB41511CEA7C0BF0@phx.gbl>,
	<A84E66CA-9A25-4991-8533-208FE241AC9E@r-project.org>
	<COL117-W30C37D77057267045E331EC0A00@phx.gbl>
Message-ID: <7A0A6598-EA8F-4AC8-A0AF-86307E63F4FE@r-project.org>

Martin,

On Jul 20, 2010, at 8:10 AM, Martin Kerr wrote:

> 
> Sorry I phrased that badly.
> What I'm trying to do is asynchronously add data to R, i.e. a program will periodically dump some readings to the Rserver and then later on another program will run some analysis scripts on them.

That is an entirely different concept - the Rserve control commands (CMD_ctrlEval and CMD_ctrlSource) allow you to do that:  evaluate code in the master server process. All subsequent clients are then working on the updated data.

However, there is no support for control commands in the C++ client so following the same directions you'd have to add it (this time there is truly no data in the response as it is asynchronous so sending the request is sufficient).


> I have managed to add the data via CMD_detachedVoidEval as you suggested. 
> How exactly do I go about attaching to the session again? I know it involves some form of session key that comes back from the detach call, but what from does it take? And how do I use this? 

The detach command will return a 32-byte session key which you use with the attach command. It is opaque to the application. However, this is a whole different story - the assumption was that you only need asynchronous evaluation so you would actually quit R in the client once detached. The session support (detach/attach) is for a different use - if you start a long computation but don't want to wait for the result and only come back later to collect the result.

Cheers,
Simon

PS: please continue the discussion on stat-rosuda-devel as that is the correct place.


> Thanks AgainMartin
>> Subject: Re: [Rd] Non-blocking Eval
>> From: simon.urbanek at r-project.org
>> Date: Mon, 19 Jul 2010 11:34:29 -0400
>> CC: r-devel at r-project.org
>> To: mk2391 at hotmail.com
>> 
>> On Jul 19, 2010, at 10:58 AM, Martin Kerr wrote:
>> 
>>> 
>>> Hello,
>>> I'm currently working with the C++ version of the Rserve Client as part of a student project.
>>> Is there an implementation of a non-blocking interface to Rserve in C++? I can find one via the Java JRI but no equivalent in C++.
>> 
>> (Please note that stats-rosuda-devel is the correct list for this.)
>> 
>> I'm not quite sure what you mean, because in JRI there is idleEval() which is non-blocking in the sense that it doesn't do anything if R is busy but that doesn't apply to Rserve as by definition R cannot be busy there. There is no non-blocking interface to JRI - all calls are synchronous.
>> 
>> If your question is whether you can start an evaluation in Rserve and not wait for the result then there is CMD_detachedVoidEval in Rserve, but the C++ client only implements a subset of the API which does not include that -- however, it is trivial to implement (just send a request with CMD_detachedVoidEval as there is nothing to decode).
>> 
>> Cheers,
>> Simon
>> 
> 		 	   		  
> _________________________________________________________________
> 
> Do you have a story that started on Hotmail? Tell us now
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> 



[Rd] Non-blocking Eval
Simon Urbanek