forked from facebook/rocksdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix/minimize mock_time_env.h dependencies (facebook#7426)
Summary: (a) own copy of kMicrosInSecond (b) out-of-line sync point code Pull Request resolved: facebook#7426 Test Plan: FB internal Reviewed By: ajkr Differential Revision: D23861363 Pulled By: pdillinger fbshipit-source-id: de6b1621dca2f7391c5ff72bad04a7613dc27527
1 parent
b005f96
commit ac1734d
Showing
5 changed files
with
45 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved. | ||
// This source code is licensed under both the GPLv2 (found in the | ||
// COPYING file in the root directory) and Apache 2.0 License | ||
// (found in the LICENSE.Apache file in the root directory). | ||
|
||
#include "test_util/mock_time_env.h" | ||
|
||
#include "test_util/sync_point.h" | ||
|
||
namespace ROCKSDB_NAMESPACE { | ||
|
||
// TODO: this is a workaround for the different behavior on different platform | ||
// for timedwait timeout. Ideally timedwait API should be moved to env. | ||
// details: PR #7101. | ||
void MockTimeEnv::InstallTimedWaitFixCallback() { | ||
#ifndef NDEBUG | ||
SyncPoint::GetInstance()->DisableProcessing(); | ||
SyncPoint::GetInstance()->ClearAllCallBacks(); | ||
#ifdef OS_MACOSX | ||
// This is an alternate way (vs. SpecialEnv) of dealing with the fact | ||
// that on some platforms, pthread_cond_timedwait does not appear to | ||
// release the lock for other threads to operate if the deadline time | ||
// is already passed. (TimedWait calls are currently a bad abstraction | ||
// because the deadline parameter is usually computed from Env time, | ||
// but is interpreted in real clock time.) | ||
SyncPoint::GetInstance()->SetCallBack( | ||
"InstrumentedCondVar::TimedWaitInternal", [&](void* arg) { | ||
uint64_t time_us = *reinterpret_cast<uint64_t*>(arg); | ||
if (time_us < this->RealNowMicros()) { | ||
*reinterpret_cast<uint64_t*>(arg) = this->RealNowMicros() + 1000; | ||
} | ||
}); | ||
#endif // OS_MACOSX | ||
SyncPoint::GetInstance()->EnableProcessing(); | ||
#endif // !NDEBUG | ||
} | ||
|
||
} // namespace ROCKSDB_NAMESPACE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters