Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 09-16-2008
soff.dong soff.dong is offline
Registered User
 
Name: qiao dong
Organization: accurad
Project: v6's net project
 
Join Date: Jun 2008
Location: china xian
Posts: 12
Send a message via MSN to soff.dong
-->
Wink Out-Parameters

Hey,guy:
i want use sequence<byte> ByteSeq as Out-Parameters, that also back big data,so i want use array mapping for achieve zero-copy passing of sequences.

How deal with it ?
TKS.
Reply With Quote
  #2 (permalink)  
Old 09-16-2008
dwayne's Avatar
dwayne dwayne is offline
ZeroC Staff
 
Name: Dwayne Boone
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Jan 2005
Location: St. John's, Newfoundland
Posts: 215
Hi,

In order to get zero-copy for return values you need to use AMI in your client and AMD in your server. Your slice might look something like

Code:
#include<Ice/BuiltinSequences.ice>

module Test
{

interface Iface
{
    ["ami", "amd"] void getBytes(out ["cpp:array"] Ice::ByteSeq b); 
};

};
See Chapter 33 of the manual for more info on AMI/AMD.

Dwayne

Last edited by dwayne : 09-16-2008 at 01:46 PM.
Reply With Quote
  #3 (permalink)  
Old 09-16-2008
soff.dong soff.dong is offline
Registered User
 
Name: qiao dong
Organization: accurad
Project: v6's net project
 
Join Date: Jun 2008
Location: china xian
Posts: 12
Send a message via MSN to soff.dong
-->
fast copy

yeah,iGet it,and other trouble is i want copy data like this:

ByteSeq byteSeq(ByteSeqSize);
pair<const Ice::Byte*, const Ice::Byte*> byteArr;
byteArr.first = &byteSeq[0];
byteArr.second = byteArr.first + byteSeq.size();


how ?

Reply With Quote
  #4 (permalink)  
Old 09-16-2008
dwayne's Avatar
dwayne dwayne is offline
ZeroC Staff
 
Name: Dwayne Boone
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Jan 2005
Location: St. John's, Newfoundland
Posts: 215
Sorry, but I don't understand your question. What is it that you want to do and what is the problem you are having doing it?
Reply With Quote
  #5 (permalink)  
Old 09-16-2008
soff.dong soff.dong is offline
Registered User
 
Name: qiao dong
Organization: accurad
Project: v6's net project
 
Join Date: Jun 2008
Location: china xian
Posts: 12
Send a message via MSN to soff.dong
-->
I'm so sorry about it.

in my project,i use Out-Parameters to get the result,but sometimes,it's huge big,so i try to use sequence<byte> out the result, i define .ice like :
sequence<byte> ByteSeq;
interface Hello
{
void sayHello(int delay,out ByteSeq byteSeq);
}


so just like client send a num,and server out back a big data,
now,i have no idea about out back ,it's so big,i want server copy data as soon as he can.
In Ice-3.2.1-VC71\demo\Ice\throughput, i found Array Mapping for Sequences,so i think maybe Array can help me to achieve zero-copy passing of sequences.

can i do it ? tks.
Reply With Quote
  #6 (permalink)  
Old 09-16-2008
soff.dong soff.dong is offline
Registered User
 
Name: qiao dong
Organization: accurad
Project: v6's net project
 
Join Date: Jun 2008
Location: china xian
Posts: 12
Send a message via MSN to soff.dong
-->
hey, dwayne

I alos read AMI/AMD.should i do that(above) without use it?
Reply With Quote
  #7 (permalink)  
Old 09-16-2008
dwayne's Avatar
dwayne dwayne is offline
ZeroC Staff
 
Name: Dwayne Boone
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Jan 2005
Location: St. John's, Newfoundland
Posts: 215
As I stated in my first response, if you want to have zero-copy for an out paramater then you need to use AMI/AMD. So if we use the slice that I used previously, on the server side your servant would implement the getBytes_async AMD method. Something like:

Code:
void
IfaceI::getBytes_async(const ::Test::AMD_Iface_getBytesPtr& cb, const ::Ice::Current& current)
{
    pair<const Ice::Byte*, const Ice::Byte*> outPair;
    // Set pair first/second to point at your data 
    cb.ice_response(outPair);
}
On the client side you would use the AMI method to call getBytes. Something like:

Code:
class AMI_Iface_getBytesI : public AMI_Iface_getBytes
{
public:

    void ice_response(const pair<const ::Ice::Byte*, const ::Ice::Byte*>& bytes)
    {
        // Do what you need to do with data
    }
    ...
};

typedef IceUtil::Handle<AMI_Iface_getBytesI> AMI_Iface_getBytesIPtr;

main()
{
    ...
    IfacePrx prx = ... // obtain proxy

    AMI_Iface_getBytesIPtr cb = new AMI_Iface_getBytesI();
    prx->getBytes_async(cb);
    ...
}
I hope this makes it clearer what you need to do to reduce the amount of copying for out parameters to a minimal. The same would apply for using return values rather than an out.

Dwayne
Reply With Quote
  #8 (permalink)  
Old 09-16-2008
bernard's Avatar
bernard bernard is offline
ZeroC Staff
 
Name: Bernard Normier
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Palm Beach Gardens, FL
Posts: 834
If you're returning a stack-allocated vector<Ice::Byte> from your servant, then with many C++ compilers, you can take advantage of Named Return Value Optimization (NRVO).

In this case, no need to use AMD to implement your operation: this compiler optimization avoids the vector copying.

Cheers,
Bernard
__________________
Bernard Normier
ZeroC, Inc.
Reply With Quote
  #9 (permalink)  
Old 09-25-2008
soff.dong soff.dong is offline
Registered User
 
Name: qiao dong
Organization: accurad
Project: v6's net project
 
Join Date: Jun 2008
Location: china xian
Posts: 12
Send a message via MSN to soff.dong
-->
Thanks a lot, for your input, these are great answers.
__________________
Reply With Quote
  #10 (permalink)  
Old 09-25-2008
soff.dong soff.dong is offline
Registered User
 
Name: qiao dong
Organization: accurad
Project: v6's net project
 
Join Date: Jun 2008
Location: china xian
Posts: 12
Send a message via MSN to soff.dong
-->
Thanks a lot, for your input, these are great answers.
__________________
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sockets parameters in ICE gyarmit Comments 2 06-19-2007 10:32 AM
in data with out parameters? ctennis Help Center 1 06-29-2006 10:48 AM
slice generated classess in c++ and unused parameters xdm Help Center 6 01-26-2006 12:31 AM
Passing parameters to constructor jacopo Help Center 2 05-12-2005 01:47 PM
Extracting Network parameters from a proxy object alfredt Help Center 1 03-03-2004 08:51 AM


All times are GMT -4. The time now is 05:25 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.