Skip to content

Commit 0487ac1

Browse files
committed
ortools: use new MutexLock ctor
1 parent 683f34b commit 0487ac1

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

ortools/lp_data/lp_decomposer.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ LPDecomposer::LPDecomposer()
3636
: original_problem_(nullptr), clusters_(), mutex_() {}
3737

3838
void LPDecomposer::Decompose(const LinearProgram* linear_problem) {
39-
absl::MutexLock mutex_lock(&mutex_);
39+
absl::MutexLock mutex_lock(mutex_);
4040
original_problem_ = linear_problem;
4141
clusters_.clear();
4242

@@ -69,12 +69,12 @@ void LPDecomposer::Decompose(const LinearProgram* linear_problem) {
6969
}
7070

7171
int LPDecomposer::GetNumberOfProblems() const {
72-
absl::MutexLock mutex_lock(&mutex_);
72+
absl::MutexLock mutex_lock(mutex_);
7373
return clusters_.size();
7474
}
7575

7676
const LinearProgram& LPDecomposer::original_problem() const {
77-
absl::MutexLock mutex_lock(&mutex_);
77+
absl::MutexLock mutex_lock(mutex_);
7878
return *original_problem_;
7979
}
8080

@@ -85,7 +85,7 @@ void LPDecomposer::ExtractLocalProblem(int problem_index, LinearProgram* lp) {
8585

8686
lp->Clear();
8787

88-
absl::MutexLock mutex_lock(&mutex_);
88+
absl::MutexLock mutex_lock(mutex_);
8989
const std::vector<ColIndex>& cluster = clusters_[problem_index];
9090
StrictITIVector<ColIndex, ColIndex> global_to_local(
9191
original_problem_->num_variables(), kInvalidCol);
@@ -143,7 +143,7 @@ DenseRow LPDecomposer::AggregateAssignments(
143143
absl::Span<const DenseRow> assignments) const {
144144
CHECK_EQ(assignments.size(), clusters_.size());
145145

146-
absl::MutexLock mutex_lock(&mutex_);
146+
absl::MutexLock mutex_lock(mutex_);
147147
DenseRow global_assignment(original_problem_->num_variables(),
148148
Fractional(0.0));
149149
for (int problem = 0; problem < assignments.size(); ++problem) {
@@ -163,7 +163,7 @@ DenseRow LPDecomposer::ExtractLocalAssignment(int problem_index,
163163
CHECK_LT(problem_index, clusters_.size());
164164
CHECK_EQ(assignment.size(), original_problem_->num_variables());
165165

166-
absl::MutexLock mutex_lock(&mutex_);
166+
absl::MutexLock mutex_lock(mutex_);
167167
const std::vector<ColIndex>& cluster = clusters_[problem_index];
168168
DenseRow local_assignment(ColIndex(cluster.size()), Fractional(0.0));
169169
for (int i = 0; i < cluster.size(); ++i) {

ortools/util/solve_interrupter.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
namespace operations_research {
2626

2727
void SolveInterrupter::Interrupt() {
28-
const absl::MutexLock lock(&mutex_);
28+
const absl::MutexLock lock(mutex_);
2929

3030
// Here we don't use compare_exchange_strong since we need to hold the lock
3131
// before changing the value of interrupted_ anyway. So there is no need to
@@ -51,7 +51,7 @@ void SolveInterrupter::Interrupt() {
5151

5252
SolveInterrupter::CallbackId SolveInterrupter::AddInterruptionCallback(
5353
Callback callback) const {
54-
const absl::MutexLock lock(&mutex_);
54+
const absl::MutexLock lock(mutex_);
5555

5656
// We must make this call while holding the lock since we want to be sure that
5757
// the calls to the callbacks_ won't occur before we registered the new
@@ -72,7 +72,7 @@ SolveInterrupter::CallbackId SolveInterrupter::AddInterruptionCallback(
7272
}
7373

7474
void SolveInterrupter::RemoveInterruptionCallback(CallbackId id) const {
75-
const absl::MutexLock lock(&mutex_);
75+
const absl::MutexLock lock(mutex_);
7676
CHECK_EQ(callbacks_.erase(id), 1) << "unregistered callback id: " << id;
7777
}
7878

ortools/util/time_limit.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -343,37 +343,37 @@ class SharedTimeLimit {
343343
bool LimitReached() const {
344344
// Note, time_limit_->LimitReached() is not const, and changes internal
345345
// state of time_limit_, hence we need a writer's lock.
346-
absl::MutexLock lock(&mutex_);
346+
absl::MutexLock lock(mutex_);
347347
return time_limit_->LimitReached();
348348
}
349349

350350
void Stop() {
351-
absl::MutexLock lock(&mutex_);
351+
absl::MutexLock lock(mutex_);
352352
*stopped_ = true;
353353
}
354354

355355
void UpdateLocalLimit(TimeLimit* local_limit) {
356-
absl::MutexLock lock(&mutex_);
356+
absl::MutexLock lock(mutex_);
357357
local_limit->MergeWithGlobalTimeLimit(time_limit_);
358358
}
359359

360360
void AdvanceDeterministicTime(double deterministic_duration) {
361-
absl::MutexLock lock(&mutex_);
361+
absl::MutexLock lock(mutex_);
362362
time_limit_->AdvanceDeterministicTime(deterministic_duration);
363363
}
364364

365365
double GetTimeLeft() const {
366-
absl::ReaderMutexLock lock(&mutex_);
366+
absl::ReaderMutexLock lock(mutex_);
367367
return time_limit_->GetTimeLeft();
368368
}
369369

370370
double GetElapsedDeterministicTime() const {
371-
absl::ReaderMutexLock lock(&mutex_);
371+
absl::ReaderMutexLock lock(mutex_);
372372
return time_limit_->GetElapsedDeterministicTime();
373373
}
374374

375375
std::atomic<bool>* ExternalBooleanAsLimit() const {
376-
absl::ReaderMutexLock lock(&mutex_);
376+
absl::ReaderMutexLock lock(mutex_);
377377
// We can simply return the "external bool" and remain thread-safe because
378378
// it's wrapped in std::atomic.
379379
return time_limit_->ExternalBooleanAsLimit();

0 commit comments

Comments
 (0)