diff options
author | Bernard Normier <bernard@zeroc.com> | 2007-06-27 20:41:24 -0400 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2007-06-27 20:41:24 -0400 |
commit | 986f11aa8cf039e3d15008a508155c363532ab7a (patch) | |
tree | 81bddb5930455639b4f02efb7cd9a053c7e0a90b /cpp | |
parent | Freeze transaction attributes + new Freeze/casino demo (diff) | |
download | ice-986f11aa8cf039e3d15008a508155c363532ab7a.tar.bz2 ice-986f11aa8cf039e3d15008a508155c363532ab7a.tar.xz ice-986f11aa8cf039e3d15008a508155c363532ab7a.zip |
Windows build fixes
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/demo/Freeze/Makefile.mak | 1 | ||||
-rw-r--r-- | cpp/demo/Freeze/casino/BankI.cpp | 14 | ||||
-rw-r--r-- | cpp/demo/Freeze/casino/BankI.h | 8 | ||||
-rw-r--r-- | cpp/demo/Freeze/casino/BetResolver.h | 7 | ||||
-rw-r--r-- | cpp/demo/Freeze/casino/Client.cpp | 5 | ||||
-rw-r--r-- | cpp/demo/Freeze/casino/Makefile.mak | 58 | ||||
-rw-r--r-- | cpp/demo/Freeze/casino/Server.cpp | 16 | ||||
-rw-r--r-- | cpp/demo/Freeze/casino/Timer.cpp | 25 | ||||
-rw-r--r-- | cpp/demo/Freeze/casino/config.server | 2 | ||||
-rw-r--r-- | cpp/demo/Freeze/casino/db/.gitignore | 15 | ||||
-rw-r--r-- | cpp/test/Freeze/evictor/config | 4 | ||||
-rw-r--r-- | cpp/test/Freeze/evictor/db/.gitignore | 1 | ||||
-rwxr-xr-x | cpp/test/Freeze/evictor/run.py | 1 |
13 files changed, 127 insertions, 30 deletions
diff --git a/cpp/demo/Freeze/Makefile.mak b/cpp/demo/Freeze/Makefile.mak index ba637591052..5c0ca44cd5d 100644 --- a/cpp/demo/Freeze/Makefile.mak +++ b/cpp/demo/Freeze/Makefile.mak @@ -13,6 +13,7 @@ top_srcdir = ..\.. SUBDIRS = bench \ backup \ + casino \ customEvictor \ library \ phonebook diff --git a/cpp/demo/Freeze/casino/BankI.cpp b/cpp/demo/Freeze/casino/BankI.cpp index d02ee272cb2..e42cde83177 100644 --- a/cpp/demo/Freeze/casino/BankI.cpp +++ b/cpp/demo/Freeze/casino/BankI.cpp @@ -75,7 +75,8 @@ BankI::checkAllChips(const Ice::Current& current) const int playerTotal = 0; Casino::PlayerPrxSeq players = getPlayers(current); - for(size_t i = 0; i < players.size(); ++i) + size_t i; + for(i = 0; i < players.size(); ++i) { playerTotal += players[i]->getChips(); } @@ -85,7 +86,7 @@ BankI::checkAllChips(const Ice::Current& current) const int betTotal = 0; vector<CasinoStore::PersistentBetPrx> bets = getBets(current.adapter); - for(size_t i = 0; i < bets.size(); ++i) + for(i = 0; i < bets.size(); ++i) { betTotal += bets[i]->getChipsInPlay(); } @@ -100,7 +101,14 @@ BankI::checkAllChips(const Ice::Current& current) const Casino::BetPrx BankI::createBet(int amount, int lifetime, const Ice::Current&) { - Ice::Identity ident = {IceUtil::generateUUID(), "bet"}; +#if defined(_MSC_VER) && (_MSC_VER < 1300) + Ice::Identity ident; + ident.name = IceUtil::generateUUID(); + ident.category = "bet"; +#else + Ice::Identity ident = { IceUtil::generateUUID(), "bet" }; +#endif + Ice::Long closeTime = IceUtil::Time::now().toMilliSeconds() + lifetime; outstandingChips += amount; diff --git a/cpp/demo/Freeze/casino/BankI.h b/cpp/demo/Freeze/casino/BankI.h index def7b7a7dc3..3c2d76ddb43 100644 --- a/cpp/demo/Freeze/casino/BankI.h +++ b/cpp/demo/Freeze/casino/BankI.h @@ -54,6 +54,14 @@ private: std::vector<CasinoStore::PersistentBetPrx> getBets(const Ice::ObjectAdapterPtr&) const; + +#if defined(_MSC_VER) && (_MSC_VER < 1300) +// +// Some compilers don't let local classes access private data members +// +public: +#endif + CasinoStore::PersistentBankPrx _prx; Freeze::TransactionalEvictorPtr _evictor; Freeze::TransactionalEvictorPtr _playerEvictor; diff --git a/cpp/demo/Freeze/casino/BetResolver.h b/cpp/demo/Freeze/casino/BetResolver.h index 468537c578c..8e08142db90 100644 --- a/cpp/demo/Freeze/casino/BetResolver.h +++ b/cpp/demo/Freeze/casino/BetResolver.h @@ -30,10 +30,17 @@ public: int getBetCount() const; +#if !defined(_MSC_VER) || (_MSC_VER >= 1300) +// +// Some compilers don't let local classes access private members +// private: +#endif void decrementBetCount(); +private: + int _betCount; IceUtil::Mutex _mutex; std::vector<TimerPtr> _timers; diff --git a/cpp/demo/Freeze/casino/Client.cpp b/cpp/demo/Freeze/casino/Client.cpp index ffb35e94ab5..0e219fc25b3 100644 --- a/cpp/demo/Freeze/casino/Client.cpp +++ b/cpp/demo/Freeze/casino/Client.cpp @@ -67,7 +67,8 @@ CasinoClient::run(int argc, char* argv[]) cout << "Create 500 10-chips bets... " << flush; - for(int b = 0; b < 500; ++b) + int b; + for(b = 0; b < 500; ++b) { Casino::BetPrx bet = bank->createBet(10, 200 + IceUtil::random(4000)); for(size_t i = 0; i < players.size(); ++i) @@ -128,7 +129,7 @@ CasinoClient::run(int argc, char* argv[]) cout << "Create 100 10-chips bets... " << flush; - for(int b = 0; b < 100; ++b) + for(b = 0; b < 100; ++b) { Casino::BetPrx bet = bank->createBet(10, 200 + IceUtil::random(4000)); for(size_t i = 0; i < players.size(); ++i) diff --git a/cpp/demo/Freeze/casino/Makefile.mak b/cpp/demo/Freeze/casino/Makefile.mak new file mode 100644 index 00000000000..783dbb039a2 --- /dev/null +++ b/cpp/demo/Freeze/casino/Makefile.mak @@ -0,0 +1,58 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +top_srcdir = ..\..\.. + +CLIENT = client.exe +SERVER = server.exe + +TARGETS = $(CLIENT) $(SERVER) + +OBJS = Casino.obj + +COBJS = Client.obj \ + +SOBJS = CasinoStore.obj \ + BankI.obj \ + BetI.obj \ + PlayerI.obj \ + BetResolver.obj \ + Timer.obj \ + Server.obj + +SRCS = $(OBJS:.obj=.cpp) \ + $(COBJS:.obj=.cpp) \ + $(SOBJS:.obj=.cpp) + +!include $(top_srcdir)/config/Make.rules.mak + +CPPFLAGS = -I. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN +SLICE2CPPFLAGS = -I. $(SLICE2CPPFLAGS) + +!if "$(CPP_COMPILER)" != "BCC2006" && "$(OPTIMIZE)" != "yes" +CPDBFLAGS = /pdb:$(CLIENT:.exe=.pdb) +SPDBFLAGS = /pdb:$(SERVER:.exe=.pdb) +!endif + +$(CLIENT): $(OBJS) $(COBJS) + $(LINK) $(LD_EXEFLAGS) $(CPDBFLAGS) $(SETARGV) $(OBJS) $(COBJS) $(PREOUT)$@ $(PRELIBS)$(LIBS) + @if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \ + $(MT) -nologo -manifest $@.manifest -outputresource:$@;#1 && del /q $@.manifest + +$(SERVER): $(OBJS) $(SOBJS) + $(LINK) $(LD_EXEFLAGS) $(SPDBFLAGS) $(SETARGV) $(OBJS) $(SOBJS) $(PREOUT)$@ $(PRELIBS)$(LIBS) freeze$(LIBSUFFIX).lib + @if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \ + $(MT) -nologo -manifest $@.manifest -outputresource:$@;#1 && del /q $@.manifest + +clean:: + del /q Casino.cpp Casino.h + del /q CasinoStore.cpp CasinoStore.h + -for %f in (db\*) do if not %f == db\.gitignore del /q %f + +!include .depend diff --git a/cpp/demo/Freeze/casino/Server.cpp b/cpp/demo/Freeze/casino/Server.cpp index 904bc826830..d5b49d2d518 100644 --- a/cpp/demo/Freeze/casino/Server.cpp +++ b/cpp/demo/Freeze/casino/Server.cpp @@ -28,14 +28,20 @@ public: private: map<string, string> createTypeMap(const string&); + const string _envName; +#if defined(_MSC_VER) && (_MSC_VER < 1300) +// +// Some compilers don't let local classes access private data members +// +public: +#endif CasinoStore::PersistentBankPrx _bankPrx; Freeze::TransactionalEvictorPtr _bankEvictor; Freeze::TransactionalEvictorPtr _playerEvictor; Freeze::TransactionalEvictorPtr _betEvictor; BetResolver _betResolver; - int _bankEdge; - const string _envName; + int _bankEdge; }; int @@ -239,7 +245,13 @@ CasinoServer::run(int argc, char* argv[]) for(size_t i = 0; i < 12; ++i) { +#if defined(_MSC_VER) && (_MSC_VER < 1300) + Ice::Identity ident; + ident.name = players[i]; + ident.category = "player"; +#else Ice::Identity ident = { players[i], "player" }; +#endif if(!_playerEvictor->hasObject(ident)) { _playerEvictor->add(new PlayerI, ident); diff --git a/cpp/demo/Freeze/casino/Timer.cpp b/cpp/demo/Freeze/casino/Timer.cpp index a76a3d51104..7be24e9e2e6 100644 --- a/cpp/demo/Freeze/casino/Timer.cpp +++ b/cpp/demo/Freeze/casino/Timer.cpp @@ -43,27 +43,39 @@ Timer::cancel() void Timer::schedule(const TimerTaskPtr& task, const IceUtil::Time& time) { +#if defined(_MSC_VER) && (_MSC_VER < 1300) + Entry entry; + entry.task = task; + entry.time = time; +#else Entry entry = { task, time }; +#endif IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); + // cout << "Scheduling task for " << time.toDateTime() << endl; + bool notify = _queue.empty(); // // Insert it at the proper position // + bool inserted = false; deque<Entry>::iterator p = _queue.begin(); - while(p != _queue.end()) + while(!inserted && p != _queue.end()) { if(time < p->time) { _queue.insert(p, entry); - break; + inserted = true; + } + else + { + ++p; } - ++p; } - if(p == _queue.end()) + if(!inserted) { _queue.push_back(entry); } @@ -103,10 +115,11 @@ Timer::run() IceUtil::Time now = IceUtil::Time::now(); ready = (entry.time <= now); - if(!ready) { - ready == (_monitor.timedWait(now - entry.time) == false); + // cout << "Waiting for " << (entry.time - now).toDuration() << endl; + + ready = (_monitor.timedWait(entry.time - now) == false); } } while(!_canceled && !ready); diff --git a/cpp/demo/Freeze/casino/config.server b/cpp/demo/Freeze/casino/config.server index b2493b916f9..b1d28a9512a 100644 --- a/cpp/demo/Freeze/casino/config.server +++ b/cpp/demo/Freeze/casino/config.server @@ -9,6 +9,8 @@ Freeze.Evictor.db.bank.RollbackOnUserException=1 Freeze.Evictor.db.bet.RollbackOnUserException=1 Freeze.Evictor.db.player.RollbackOnUserException=1 +#Freeze.Trace.Transaction=1 + # # The bank can have more chances of winning than regular players. # must be >= 1 diff --git a/cpp/demo/Freeze/casino/db/.gitignore b/cpp/demo/Freeze/casino/db/.gitignore index 54621e8e1aa..39af5887579 100644 --- a/cpp/demo/Freeze/casino/db/.gitignore +++ b/cpp/demo/Freeze/casino/db/.gitignore @@ -1,14 +1 @@ -// Generated by makegitignore.py - -// IMPORTANT: Do not edit this file -- any edits made here will be lost! -client -server -collocated -Library.cpp -Library.h -db/* -LibraryTypes.h -LibraryTypes.cpp -Grammar.cpp -Grammar.h -Scanner.cpp +# Dummy file, so that git retains this otherwise empty directory. diff --git a/cpp/test/Freeze/evictor/config b/cpp/test/Freeze/evictor/config index 845603239f8..2681299fea8 100644 --- a/cpp/test/Freeze/evictor/config +++ b/cpp/test/Freeze/evictor/config @@ -3,10 +3,10 @@ Freeze.Evictor.db.Test.SavePeriod=2 #Freeze.Trace.Evictor=1 #Freeze.Trace.DbEnv=3 +#Freeze.Trace.Transaction=1 +#Freeze.Warn.Deadlocks=1 Ice.ThreadPool.Server.SizeMax=20 Ice.ThreadPool.Server.SizeWarn=0 Freeze.Evictor.db.Test.RollbackOnUserException=1 - -#Freeze.Warn.Deadlocks=1 diff --git a/cpp/test/Freeze/evictor/db/.gitignore b/cpp/test/Freeze/evictor/db/.gitignore deleted file mode 100644 index 39af5887579..00000000000 --- a/cpp/test/Freeze/evictor/db/.gitignore +++ /dev/null @@ -1 +0,0 @@ -# Dummy file, so that git retains this otherwise empty directory. diff --git a/cpp/test/Freeze/evictor/run.py b/cpp/test/Freeze/evictor/run.py index 6f2fbd8d1c5..b642a7cb52f 100755 --- a/cpp/test/Freeze/evictor/run.py +++ b/cpp/test/Freeze/evictor/run.py @@ -28,5 +28,6 @@ TestUtil.cleanDbDir(dbdir) testOptions = " --Freeze.DbEnv.db.DbHome=" + testdir + "/db" + " --Ice.Config=" + testdir + "/config "; +print testOptions TestUtil.clientServerTestWithOptions(name, testOptions, testOptions) sys.exit(0) |