Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 06-25-2007
bambuk bambuk is offline
Registered User
 
Name: Alex Stovboun
Organization: UBS AG
Project: Financial applications
 
Join Date: Jun 2007
Posts: 6
Expensive return by value

I have a server-side method that returns a sequence to the client:

Code:
sequence<Position> PositionList;
	
interface ServerOps {
	PositionList GetPositions();
};
The C++ abstract class produced by slice2cpp dictates that GetPosition() returned vector<Position> by value which is expensive for bigger vectors.

Is it possible to return a smart pointer instead? If not, what other solutions exist?
Reply With Quote
  #2 (permalink)  
Old 06-25-2007
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,781
You could wrap the sequence in a class:

Code:
sequence<Position> PositionList;

class SharedPositionList
{
    PostionList list;
};
	
interface ServerOps {
	SharedPositionList GetPositions();
};
Reply With Quote
  #3 (permalink)  
Old 06-25-2007
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 can take advantage of "named return value optimization" (NRVO), this return copy will be optimized out.

If you can't, you could use AMD (asynchronous method dispatch) in your server for this operation. The "return" parameter becomes an "in" parameter on the AMD callback.

Best regards,
Bernard
__________________
Bernard Normier
ZeroC, Inc.
Reply With Quote
  #4 (permalink)  
Old 06-25-2007
matthew's Avatar
matthew matthew is online now
ZeroC Staff
 
Name: Matthew Newhook
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Feb 2003
Location: NL, Canada
Posts: 1,088
Note that this topic, and others, were covered in my article "Optimizing Performance of File Transfers " in http://www.zeroc.com/newsletter/issue20.pdf
Reply With Quote
  #5 (permalink)  
Old 06-26-2007
bambuk bambuk is offline
Registered User
 
Name: Alex Stovboun
Organization: UBS AG
Project: Financial applications
 
Join Date: Jun 2007
Posts: 6
Quote:
Originally Posted by marc View Post
You could wrap the sequence in a class:

Code:
sequence<Position> PositionList;

class SharedPositionList
{
    PostionList list;
};
	
interface ServerOps {
	SharedPositionList GetPositions();
};
How does this help? A copy of the SharedPositionList will be returned which will contain a COPY of PositionList.
Reply With Quote
  #6 (permalink)  
Old 06-26-2007
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,781
Instances of classes are passed as smart pointer, so when you copy SharedPositionList, you only increment the reference count. No data is copied.
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
In AMI ,why did not foo_async return ? AaronIct Help Center 3 04-12-2007 05:03 AM
About return struct billwillman Help Center 7 10-16-2006 03:39 AM
Why does the function of checkedCast() return 0??? OliveGirl Help Center 1 05-25-2006 04:52 AM
why return false ? OrNot Help Center 2 01-04-2006 02:50 AM
return value of getPropertyAsInt n2503v Help Center 3 10-19-2005 05:58 PM


All times are GMT -4. The time now is 11:52 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.