# HG changeset patch # User Alain Mazy # Date 1772629956 -3600 # Node ID 2c557f38484a3a88ec8d2ea20ad8c2891fdc26da # Parent 84666f4794574ddd91e6b6529ff5d415adeca9df Use size_t in Semaphore instead of unsigned int diff -r 84666f479457 -r 2c557f38484a OrthancFramework/Sources/MultiThreading/Semaphore.cpp --- 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_); diff -r 84666f479457 -r 2c557f38484a OrthancFramework/Sources/MultiThreading/Semaphore.h --- 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) {