OpenMS
Loading...
Searching...
No Matches
OpenSwathWorkflowScheduler::ConcurrencyLimiter Class Reference

Counting semaphore for paths that still stream one SWATH per worker. More...

#include <OpenMS/ANALYSIS/OPENSWATH/OpenSwathWorkflowScheduler.h>

Collaboration diagram for OpenSwathWorkflowScheduler::ConcurrencyLimiter:
[legend]

Public Member Functions

 ConcurrencyLimiter (Size max_concurrent_swaths)
 Construct with the upper bound on concurrent slots; values < 1 are clamped to 1.
 
void acquireSlot ()
 Block until a slot is free and reserve it. Wakes via the condition variable.
 
void releaseSlot ()
 Release a previously reserved slot and notify one waiter. No-op (safe) if the active count is already zero.
 

Private Attributes

Size max_concurrent_swaths_
 
Size active_swaths_ = 0
 
std::mutex mutex_
 
std::condition_variable cv_
 

Detailed Description

Counting semaphore for paths that still stream one SWATH per worker.

A small wrapper around a std::mutex + std::condition_variable pair that enforces an upper bound on concurrently-active slots. The constructor clamps the requested cap to max(1, max_concurrent_swaths) so callers don't accidentally configure an unreachable limit. Not copyable nor movable (inherited from the mutex and condition variable members).

Pair with ScopedSlot for RAII slot management instead of calling acquireSlot / releaseSlot directly.

Constructor & Destructor Documentation

◆ ConcurrencyLimiter()

ConcurrencyLimiter ( Size  max_concurrent_swaths)
explicit

Construct with the upper bound on concurrent slots; values < 1 are clamped to 1.

Member Function Documentation

◆ acquireSlot()

void acquireSlot ( )

Block until a slot is free and reserve it. Wakes via the condition variable.

◆ releaseSlot()

void releaseSlot ( )

Release a previously reserved slot and notify one waiter. No-op (safe) if the active count is already zero.

Member Data Documentation

◆ active_swaths_

Size active_swaths_ = 0
private

◆ cv_

std::condition_variable cv_
private

◆ max_concurrent_swaths_

Size max_concurrent_swaths_
private

◆ mutex_

std::mutex mutex_
private