Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
operations_research::math_opt::ConcurrentCallsGuard Class Reference

#include <concurrent_calls_guard.h>

Classes

class  Tracker
 Tracker for pending calls. More...
 

Public Member Functions

 ConcurrentCallsGuard (const ConcurrentCallsGuard &)=delete
 
ConcurrentCallsGuardoperator= (const ConcurrentCallsGuard &)=delete
 
ConcurrentCallsGuardoperator= (ConcurrentCallsGuard &&)=delete
 
 ConcurrentCallsGuard (ConcurrentCallsGuard &&other) noexcept
 
 ~ConcurrentCallsGuard ()
 Release the guard.
 

Static Public Member Functions

static absl::StatusOr< ConcurrentCallsGuardTryAcquire (Tracker &tracker)
 

Detailed Description

RAII class that is used to return an error when concurrent calls to some functions are made.

Usage:

///< Calling f() and/or g() concurrently will return an error. class A { public: absl::StatusOr<...> f() { ASSIGN_OR_RETURN(const auto guard, ConcurrentCallsGuard::TryAcquire(tracker_)); ... }

absl::StatusOr<...> g() {
ASSIGN_OR_RETURN(const auto guard,
...
}
private:
#define ASSIGN_OR_RETURN(lhs, rexpr)
static absl::StatusOr< ConcurrentCallsGuard > TryAcquire(Tracker &tracker)

};

Definition at line 50 of file concurrent_calls_guard.h.

Constructor & Destructor Documentation

◆ ConcurrentCallsGuard() [1/2]

operations_research::math_opt::ConcurrentCallsGuard::ConcurrentCallsGuard ( const ConcurrentCallsGuard & )
delete

◆ ConcurrentCallsGuard() [2/2]

operations_research::math_opt::ConcurrentCallsGuard::ConcurrentCallsGuard ( ConcurrentCallsGuard && other)
inlinenoexcept

Definition at line 75 of file concurrent_calls_guard.h.

◆ ~ConcurrentCallsGuard()

operations_research::math_opt::ConcurrentCallsGuard::~ConcurrentCallsGuard ( )

Release the guard.

Definition at line 36 of file concurrent_calls_guard.cc.

Member Function Documentation

◆ operator=() [1/2]

ConcurrentCallsGuard & operations_research::math_opt::ConcurrentCallsGuard::operator= ( ConcurrentCallsGuard && )
delete

◆ operator=() [2/2]

ConcurrentCallsGuard & operations_research::math_opt::ConcurrentCallsGuard::operator= ( const ConcurrentCallsGuard & )
delete

◆ TryAcquire()

absl::StatusOr< ConcurrentCallsGuard > operations_research::math_opt::ConcurrentCallsGuard::TryAcquire ( Tracker & tracker)
static

Returns an errors status when concurrent calls are made, or a guard that must only be kept on stack during the execution of the call.

Definition at line 24 of file concurrent_calls_guard.cc.


The documentation for this class was generated from the following files: