From a5e8e088e743c68f22a0554a0c56cf3d2c8faa26 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 18 Nov 2015 00:05:57 +0000 Subject: Add missing doxygen comments --- libadhocutil/resourcePool.h | 21 ++++++++++++++++++++- 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; + /// 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 get(); - ResourceHandle get(unsigned int); + /// Get a resource from the pool (with timeout on max size of pool) + /// @param ms Timeout in milliseconds. + ResourceHandle get(unsigned int ms); + /// Get a new handle to the resource previous allocated to the current. ResourceHandle 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; -- cgit v1.2.3