Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 07-12-2007
solikhin solikhin is offline
Registered User
 
Name: solikhin solikhin
Organization: UII Yogyakarta
Project: Converting inhouse 2 tier to 3 tier architecture
 
Join Date: Jul 2007
Posts: 9
global variable and thread issue in ice

Hello,

I'm new to Ice. I want to store some aplication-wide variables in ice server application (this is reguler ice application, not using icebox / icegrid). I did this by placing those global variables in the main class of the object. So far so good for 1 client, but I wonder is this the correct way to do such thing ?. I mean, I'm afraid that every client will have their own fresh copy of server instance in separate thread instead of one instance of server object for all client. How ice server serve client's request, 1 instance for all clients or 1 instance (in separate thread) for 1 client ?.

Thanks in advance for your help,
regards,
solikhin
Reply With Quote
  #2 (permalink)  
Old 07-12-2007
benoit's Avatar
benoit benoit is offline
ZeroC Staff
 
Name: Benoit Foucher
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Rennes, France
Posts: 1,564
Hi,

I assume you meant "servant" by "main class of the object" (see this FAQ for the correct terminology). It's not quite clear to me what you're doing (perhaps you can post some sample code to demonstrate it?). But if you have registered the servant with the object adapter and your clients invoke on the Ice object incarnated by the servant with a proxy that only points to this Ice object, your clients will use the same instance of the object.

Cheers,
Benoit.
Reply With Quote
  #3 (permalink)  
Old 07-12-2007
solikhin solikhin is offline
Registered User
 
Name: solikhin solikhin
Organization: UII Yogyakarta
Project: Converting inhouse 2 tier to 3 tier architecture
 
Join Date: Jul 2007
Posts: 9
re:global variable and thread issue in ice

Thanks for your quick reply,

Here is an ilustration on what I mean with "the main class of the object" :

class HelloI : public Demo::Hello
{
public:
virtual void sayHello(int delay,const Ice::current&) const;
virtual void shutdown(const Ice::current&);

// Here I put some global variables
// ie: some connection to the "in memory" database
}

Those variables will be initialized during the creation of those class. I expect to only have 1 instance of this class (regardless of the number of client connection) so that the content of in memory database will be consistent on all client. Is that the correct way to do such thing ?.
Reply With Quote
  #4 (permalink)  
Old 07-12-2007
benoit's Avatar
benoit benoit is offline
ZeroC Staff
 
Name: Benoit Foucher
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Rennes, France
Posts: 1,564
Yes, there will only be one servant instance for the Ice object if you register this servant with the object adapter. Invocations from different clients will be dispatched with the same servant instance.

Cheers,
Benoit.
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
patch #3 for Ice 3.2: Fix for condition variable implementation under Windows. matthew Patches 3 08-13-2008 03:35 PM
Java global package metadata and builtin datatypes mefoster Bug Reports 1 05-11-2007 12:27 PM
visual Studio & ice 3.0 & Global Assembly Cache loheron Help Center 7 11-23-2006 08:39 AM
IcePy and The global interpreter lock rc_hz Comments 1 10-17-2006 10:50 AM
Question about ICE_CONFIG environment variable in Ice for java ? rc_hz Comments 2 09-18-2006 06:54 AM


All times are GMT -4. The time now is 12:48 AM.


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.