diff options
author | Michi Henning <michi@zeroc.com> | 2007-07-31 11:16:56 +1000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2007-07-31 11:16:56 +1000 |
commit | dbca25cd1c71fa775670c66e26ff7a0f5831ae29 (patch) | |
tree | eeef25bc75f6d9d977b3199ddfe58dd723fdef6b /cpp | |
parent | Ran makegitignore.py (diff) | |
download | ice-dbca25cd1c71fa775670c66e26ff7a0f5831ae29.tar.bz2 ice-dbca25cd1c71fa775670c66e26ff7a0f5831ae29.tar.xz ice-dbca25cd1c71fa775670c66e26ff7a0f5831ae29.zip |
Added project files for C#. Fixed broken locking in demo.
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/CHANGES | 2 | ||||
-rw-r--r-- | cpp/demo/book/lifecycle/FilesystemI.cpp | 36 | ||||
-rw-r--r-- | cpp/demo/book/lifecycle/FilesystemI.h | 2 |
3 files changed, 22 insertions, 18 deletions
diff --git a/cpp/CHANGES b/cpp/CHANGES index b5a5fe7f4e2..a0917254c7a 100644 --- a/cpp/CHANGES +++ b/cpp/CHANGES @@ -70,6 +70,8 @@ Changes since version 3.2.X (binary incompatible) Changes since version 3.2.0 --------------------------- +- Added demo book/lifecycle. + - Added two new IceGrid properties: IceGrid.Registry.SessionFilters diff --git a/cpp/demo/book/lifecycle/FilesystemI.cpp b/cpp/demo/book/lifecycle/FilesystemI.cpp index 9b786c325ff..0a86ed6169e 100644 --- a/cpp/demo/book/lifecycle/FilesystemI.cpp +++ b/cpp/demo/book/lifecycle/FilesystemI.cpp @@ -15,6 +15,7 @@ using namespace Ice; using namespace Filesystem; using namespace FilesystemI; +IceUtil::StaticMutex FilesystemI::DirectoryI::_lcMutex = ICE_STATIC_MUTEX_INITIALIZER; FilesystemI::DirectoryI::ReapMap FilesystemI::DirectoryI::_reapMap; // Slice Node::name() operation. @@ -90,7 +91,7 @@ FilesystemI::FileI::destroy(const Current& c) _destroyed = true; } - IceUtil::Mutex::Lock lock(_parent->_lcMutex); + IceUtil::StaticMutex::Lock lock(DirectoryI::_lcMutex); c.adapter->remove(id()); _parent->addReapEntry(_name); @@ -120,7 +121,7 @@ FilesystemI::DirectoryI::list(const Current& c) } } - IceUtil::Mutex::Lock lock(_lcMutex); + IceUtil::StaticMutex::Lock lock(_lcMutex); reap(); @@ -150,7 +151,7 @@ FilesystemI::DirectoryI::find(const string& name, const Current& c) } } - IceUtil::Mutex::Lock lock(_lcMutex); + IceUtil::StaticMutex::Lock lock(_lcMutex); reap(); @@ -182,7 +183,7 @@ FilesystemI::DirectoryI::createFile(const string& name, const Current& c) } } - IceUtil::Mutex::Lock lock(_lcMutex); + IceUtil::StaticMutex::Lock lock(_lcMutex); reap(); @@ -209,7 +210,7 @@ FilesystemI::DirectoryI::createDirectory(const string& name, const Current& c) } } - IceUtil::Mutex::Lock lock(_lcMutex); + IceUtil::StaticMutex::Lock lock(_lcMutex); reap(); @@ -227,31 +228,31 @@ FilesystemI::DirectoryI::createDirectory(const string& name, const Current& c) void FilesystemI::DirectoryI::destroy(const Current& c) { + if(!_parent) { throw PermissionDenied("Cannot destroy root directory"); } - { - IceUtil::Mutex::Lock lock(_m); + IceUtil::Mutex::Lock lock(_m); - if(_destroyed) - { - throw ObjectNotExistException(__FILE__, __LINE__); - } - if(!_contents.empty()) - { - throw PermissionDenied("Cannot destroy non-empty directory"); - } - _destroyed = true; + if(_destroyed) + { + throw ObjectNotExistException(__FILE__, __LINE__); } - IceUtil::Mutex::Lock lock(_lcMutex); + IceUtil::StaticMutex::Lock lcLock(_lcMutex); reap(); + if(!_contents.empty()) + { + throw PermissionDenied("Cannot destroy non-empty directory"); + } + c.adapter->remove(id()); _parent->addReapEntry(_name); + _destroyed = true; } // DirectoryI constructor. @@ -279,6 +280,7 @@ FilesystemI::DirectoryI::addChild(const string& name, const NodeIPtr& node) _contents[name] = node; } + // Add this directory and the name of a deleted entry to the reap map. void diff --git a/cpp/demo/book/lifecycle/FilesystemI.h b/cpp/demo/book/lifecycle/FilesystemI.h index ae3c42c7d79..ca8fa9e968f 100644 --- a/cpp/demo/book/lifecycle/FilesystemI.h +++ b/cpp/demo/book/lifecycle/FilesystemI.h @@ -67,7 +67,7 @@ namespace FilesystemI void addReapEntry(const ::std::string&); - IceUtil::Mutex _lcMutex; + static IceUtil::StaticMutex _lcMutex; private: typedef ::std::map< ::std::string, NodeIPtr> Contents; |