Mercurial > hg > orthanc
changeset 6611:2c557f38484a
Use size_t in Semaphore instead of unsigned int
| author | Alain Mazy <am@orthanc.team> |
|---|---|
| date | Wed, 04 Mar 2026 14:12:36 +0100 |
| parents | 84666f479457 |
| children | 81f91290f91e efa9c6284f83 |
| files | OrthancFramework/Sources/MultiThreading/Semaphore.cpp OrthancFramework/Sources/MultiThreading/Semaphore.h |
| diffstat | 2 files changed, 15 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancFramework/Sources/MultiThreading/Semaphore.cpp Sun Mar 01 21:14:23 2026 +0100 +++ b/OrthancFramework/Sources/MultiThreading/Semaphore.cpp Wed Mar 04 14:12:36 2026 +0100 @@ -30,17 +30,17 @@ namespace Orthanc { - Semaphore::Semaphore(unsigned int availableResources) : + Semaphore::Semaphore(size_t availableResources) : availableResources_(availableResources) { } - unsigned int Semaphore::GetAvailableResourcesCount() const + size_t Semaphore::GetAvailableResourcesCount() const { return availableResources_; } - void Semaphore::Release(unsigned int resourceCount) + void Semaphore::Release(size_t resourceCount) { boost::mutex::scoped_lock lock(mutex_); @@ -48,7 +48,7 @@ condition_.notify_one(); } - void Semaphore::Acquire(unsigned int resourceCount) + void Semaphore::Acquire(size_t resourceCount) { boost::mutex::scoped_lock lock(mutex_); @@ -60,7 +60,7 @@ availableResources_ -= resourceCount; } - bool Semaphore::TryAcquire(unsigned int resourceCount) + bool Semaphore::TryAcquire(size_t resourceCount) { boost::mutex::scoped_lock lock(mutex_);
--- a/OrthancFramework/Sources/MultiThreading/Semaphore.h Sun Mar 01 21:14:23 2026 +0100 +++ b/OrthancFramework/Sources/MultiThreading/Semaphore.h Wed Mar 04 14:12:36 2026 +0100 @@ -34,29 +34,29 @@ class ORTHANC_PUBLIC Semaphore : public boost::noncopyable { private: - unsigned int availableResources_; + size_t availableResources_; boost::mutex mutex_; boost::condition_variable condition_; public: - explicit Semaphore(unsigned int availableResources); + explicit Semaphore(size_t availableResources); - unsigned int GetAvailableResourcesCount() const; + size_t GetAvailableResourcesCount() const; - void Release(unsigned int resourceCount = 1); + void Release(size_t resourceCount = 1); - void Acquire(unsigned int resourceCount = 1); + void Acquire(size_t resourceCount = 1); - bool TryAcquire(unsigned int resourceCount = 1); + bool TryAcquire(size_t resourceCount = 1); class Locker : public boost::noncopyable { private: Semaphore& that_; - unsigned int resourceCount_; + size_t resourceCount_; public: - explicit Locker(Semaphore& that, unsigned int resourceCount = 1) : + explicit Locker(Semaphore& that, size_t resourceCount = 1) : that_(that), resourceCount_(resourceCount) { @@ -73,11 +73,11 @@ { private: Semaphore& that_; - unsigned int resourceCount_; + size_t resourceCount_; bool isAcquired_; public: - explicit TryLocker(Semaphore& that, unsigned int resourceCount = 1) : + explicit TryLocker(Semaphore& that, size_t resourceCount = 1) : that_(that), resourceCount_(resourceCount) {
