diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2016-06-08 17:13:49 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2016-06-10 18:00:48 -0400 |
commit | 9d7981ac25bae25c7764c44eb6bd58942a1aae43 (patch) | |
tree | 2658a7fb2b7199377d04a2a5f8f19c788380e8e3 /src/mongo/db/s/operation_sharding_state.cpp | |
parent | 029938758e4f9c7079e2363bf5e56c1452c20426 (diff) | |
download | mongo-9d7981ac25bae25c7764c44eb6bd58942a1aae43.tar.gz |
SERVER-24479 Make 'Notification' class be able to return a value
Diffstat (limited to 'src/mongo/db/s/operation_sharding_state.cpp')
-rw-r--r-- | src/mongo/db/s/operation_sharding_state.cpp | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/src/mongo/db/s/operation_sharding_state.cpp b/src/mongo/db/s/operation_sharding_state.cpp index c6fe82ff6d0..97991dc27f8 100644 --- a/src/mongo/db/s/operation_sharding_state.cpp +++ b/src/mongo/db/s/operation_sharding_state.cpp @@ -1,30 +1,30 @@ -/* -* Copyright (C) 2015 MongoDB Inc. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero General Public License, version 3, -* as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. -* -* As a special exception, the copyright holders give permission to link the -* code of portions of this program with the OpenSSL library under certain -* conditions as described in each individual source file and distribute -* linked combinations including the program with the OpenSSL library. You -* must comply with the GNU Affero General Public License in all respects for -* all of the code used other than as permitted herein. If you modify file(s) -* with this exception, you may extend this exception to your version of the -* file(s), but you are not obligated to do so. If you do not wish to do so, -* delete this exception statement from your version. If you delete this -* exception statement from all source files in the program, then also delete -* it in the license file. -*/ +/** + * Copyright (C) 2015 MongoDB Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the GNU Affero General Public License in all respects + * for all of the code used other than as permitted herein. If you modify + * file(s) with this exception, you may extend this exception to your + * version of the file(s), but you are not obligated to do so. If you do not + * wish to do so, delete this exception statement from your version. If you + * delete this exception statement from all source files in the program, + * then also delete it in the license file. + */ #include "mongo/platform/basic.h" @@ -96,26 +96,27 @@ void OperationShardingState::setShardVersion(NamespaceString nss, ChunkVersion n _hasVersion = true; } -bool OperationShardingState::waitForMigrationCriticalSection(OperationContext* txn) { +bool OperationShardingState::waitForMigrationCriticalSectionSignal(OperationContext* txn) { // Must not block while holding a lock invariant(!txn->lockState()->isLocked()); - if (_migrationCriticalSection) { - _migrationCriticalSection->waitUntilOutOfCriticalSection( + if (_migrationCriticalSectionSignal) { + _migrationCriticalSectionSignal->waitFor( + txn, txn->hasDeadline() ? std::min(txn->getRemainingMaxTimeMicros(), kMaxWaitForMigrationCriticalSection) : kMaxWaitForMigrationCriticalSection); - _migrationCriticalSection = nullptr; + _migrationCriticalSectionSignal = nullptr; return true; } return false; } -void OperationShardingState::setMigrationCriticalSection( - std::shared_ptr<MigrationSourceManager::CriticalSectionState> critSec) { - invariant(critSec); - _migrationCriticalSection = std::move(critSec); +void OperationShardingState::setMigrationCriticalSectionSignal( + std::shared_ptr<Notification<void>> critSecSignal) { + invariant(critSecSignal); + _migrationCriticalSectionSignal = std::move(critSecSignal); } void OperationShardingState::_clear() { |