diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-11-18 00:05:57 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-11-18 00:05:57 +0000 |
commit | a5e8e088e743c68f22a0554a0c56cf3d2c8faa26 (patch) | |
tree | 895c763423381bc8d438fa4bf352d53bf14bbf26 | |
parent | Add missing test for semaphore inital value (diff) | |
download | libadhocutil-a5e8e088e743c68f22a0554a0c56cf3d2c8faa26.tar.bz2 libadhocutil-a5e8e088e743c68f22a0554a0c56cf3d2c8faa26.tar.xz libadhocutil-a5e8e088e743c68f22a0554a0c56cf3d2c8faa26.zip |
Add missing doxygen comments
-rw-r--r-- | libadhocutil/resourcePool.h | 21 | ||||
-rw-r--r-- | libadhocutil/semaphore.h | 7 |
2 files changed, 26 insertions, 2 deletions
diff --git a/libadhocutil/resourcePool.h b/libadhocutil/resourcePool.h index 70d9ae2..f3683ae 100644 --- a/libadhocutil/resourcePool.h +++ b/libadhocutil/resourcePool.h @@ -24,13 +24,18 @@ namespace AdHoc { /// Create a reference to a new resource. ResourceHandle(Object *); + /// Create a reference to an existing resource. ResourceHandle(const ResourceHandle &); ~ResourceHandle(); + /// Reference to an existing resource. void operator=(const ResourceHandle &); + /// Access to the resource. Resource * operator->() const; + /// Access to the resource. Resource * get() const; + /// Get number of handles to this resource. unsigned int handleCount() const; private: @@ -46,20 +51,33 @@ namespace AdHoc { public: friend class ResourceHandle<Resource>; + /// Create a new resource pool. + /// @param maxSize The upper limit of how many concurrent active resources there can be. + /// @param keep The number of resources to cache for reuse. ResourcePool(unsigned int maxSize, unsigned int keep); virtual ~ResourcePool(); + /// Get a resource from the pool (maybe cached, maybe constructed afresh) ResourceHandle<Resource> get(); - ResourceHandle<Resource> get(unsigned int); + /// Get a resource from the pool (with timeout on max size of pool) + /// @param ms Timeout in milliseconds. + ResourceHandle<Resource> get(unsigned int ms); + /// Get a new handle to the resource previous allocated to the current. ResourceHandle<Resource> getMine(); + /// Go idle; destroy all cached resources, currently active instances are untouched. void idle(); + /// Get number of active resources. unsigned int inUseCount() const; + /// Get number of available cached resources. unsigned int availableCount() const; protected: + /// Create a new resource instance to add to the pool. virtual Resource * createResource() const = 0; + /// Destroy an existing resource (defaults to delete). virtual void destroyResource(Resource *) const; + /// Test a cached resource is still suitable for use (defaults to no-op). virtual void testResource(const Resource *) const; private: @@ -82,6 +100,7 @@ namespace AdHoc { /// Represents a failure to acquire a new resource within the given timeout. class DLL_PUBLIC TimeOutOnResourcePool : public AdHoc::StdException { public: + /// Constrcut a new timeout exception for the given resource type. TimeOutOnResourcePool(const char * const type); std::string message() const throw() override; diff --git a/libadhocutil/semaphore.h b/libadhocutil/semaphore.h index de10333..3e7e476 100644 --- a/libadhocutil/semaphore.h +++ b/libadhocutil/semaphore.h @@ -12,11 +12,16 @@ namespace AdHoc { /// A portable semaphore with timeout support class DLL_PUBLIC Semaphore { public: + /// Construct a new semaphore with optional initial count. Semaphore(unsigned int initial = 0); + /// Notify one waiting thread. void notify(); + /// Wait for a single count. void wait(); - bool wait(unsigned int); + /// Wait for a single count with timeout. + /// @param ms Timeout in milliseconds. + bool wait(unsigned int ms); private: boost::mutex mutex; |