Add random delay to AsyncTaskThread::execAsync in simulation
This commit is contained in:
parent
f3c52ed41e
commit
456a7c77a2
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* AsyncTaskThread.cpp
|
||||
*
|
||||
* This source file is part of the FoundationDB open source project
|
||||
*
|
||||
* Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "fdbclient/AsyncTaskThread.h"
|
||||
|
||||
const double AsyncTaskThread::meanDelay = 0.01;
|
|
@ -70,6 +70,8 @@ class AsyncTaskThread {
|
|||
}
|
||||
}
|
||||
|
||||
static const double meanDelay;
|
||||
|
||||
public:
|
||||
AsyncTaskThread() : thread([this] { run(this); }) {}
|
||||
|
||||
|
@ -77,8 +79,7 @@ public:
|
|||
auto execAsync(const F& func, TaskPriority priority = TaskPriority::DefaultOnMainThread)
|
||||
-> Future<decltype(func())> {
|
||||
if (g_network->isSimulated()) {
|
||||
// TODO: Add some random delay
|
||||
return func();
|
||||
return map(delayJittered(meanDelay), [func](Void _) { return func(); });
|
||||
}
|
||||
Promise<decltype(func())> promise;
|
||||
addTask([&promise, &func, priority] {
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
set(FDBCLIENT_SRCS
|
||||
AsyncFileBlobStore.actor.cpp
|
||||
AsyncFileBlobStore.actor.h
|
||||
AsyncTaskThread.cpp
|
||||
AsyncTaskThread.h
|
||||
Atomic.h
|
||||
AutoPublicAddress.cpp
|
||||
AsyncTaskThread.h
|
||||
BackupAgent.actor.h
|
||||
BackupAgentBase.actor.cpp
|
||||
BackupContainer.actor.cpp
|
||||
|
|
Loading…
Reference in New Issue