mirror of
https://github.com/google/leveldb.git
synced 2024-11-24 04:12:14 +08:00
Address comments.
This commit is contained in:
parent
89ea7f2643
commit
13ebad24dc
@ -1723,7 +1723,8 @@ TEST_F(DBTest, DestroyEmptyDir) {
|
|||||||
std::vector<std::string> children;
|
std::vector<std::string> children;
|
||||||
ASSERT_LEVELDB_OK(env.GetChildren(dbname, &children));
|
ASSERT_LEVELDB_OK(env.GetChildren(dbname, &children));
|
||||||
#if defined(LEVELDB_PLATFORM_CHROMIUM)
|
#if defined(LEVELDB_PLATFORM_CHROMIUM)
|
||||||
// Chromium's file system abstraction always filters out '.' and '..'.
|
// TODO(https://crbug.com/1428746): Chromium's file system abstraction always
|
||||||
|
// filters out '.' and '..'.
|
||||||
ASSERT_EQ(0, children.size());
|
ASSERT_EQ(0, children.size());
|
||||||
#else
|
#else
|
||||||
// The stock Env's do not filter out '.' and '..' special files.
|
// The stock Env's do not filter out '.' and '..' special files.
|
||||||
|
@ -96,45 +96,40 @@ TEST_F(EnvTest, RunMany) {
|
|||||||
struct RunState {
|
struct RunState {
|
||||||
port::Mutex mu;
|
port::Mutex mu;
|
||||||
port::CondVar cvar{&mu};
|
port::CondVar cvar{&mu};
|
||||||
int run_count = 0;
|
int last_id = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Callback {
|
struct Callback {
|
||||||
RunState* const state_; // Pointer to shared state.
|
RunState* state_; // Pointer to shared state.
|
||||||
bool run = false;
|
const int id_; // Order# for the execution of this callback.
|
||||||
|
|
||||||
Callback(RunState* s) : state_(s) {}
|
Callback(RunState* s, int id) : state_(s), id_(id) {}
|
||||||
|
|
||||||
static void Run(void* arg) {
|
static void Run(void* arg) {
|
||||||
Callback* callback = reinterpret_cast<Callback*>(arg);
|
Callback* callback = reinterpret_cast<Callback*>(arg);
|
||||||
RunState* state = callback->state_;
|
RunState* state = callback->state_;
|
||||||
|
|
||||||
MutexLock l(&state->mu);
|
MutexLock l(&state->mu);
|
||||||
state->run_count++;
|
ASSERT_EQ(state->last_id, callback->id_ - 1);
|
||||||
callback->run = true;
|
state->last_id = callback->id_;
|
||||||
state->cvar.Signal();
|
state->cvar.Signal();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
RunState state;
|
RunState state;
|
||||||
Callback callback1(&state);
|
Callback callback1(&state, 1);
|
||||||
Callback callback2(&state);
|
Callback callback2(&state, 2);
|
||||||
Callback callback3(&state);
|
Callback callback3(&state, 3);
|
||||||
Callback callback4(&state);
|
Callback callback4(&state, 4);
|
||||||
env_->Schedule(&Callback::Run, &callback1);
|
env_->Schedule(&Callback::Run, &callback1);
|
||||||
env_->Schedule(&Callback::Run, &callback2);
|
env_->Schedule(&Callback::Run, &callback2);
|
||||||
env_->Schedule(&Callback::Run, &callback3);
|
env_->Schedule(&Callback::Run, &callback3);
|
||||||
env_->Schedule(&Callback::Run, &callback4);
|
env_->Schedule(&Callback::Run, &callback4);
|
||||||
|
|
||||||
MutexLock l(&state.mu);
|
MutexLock l(&state.mu);
|
||||||
while (state.run_count != 4) {
|
while (state.last_id != 4) {
|
||||||
state.cvar.Wait();
|
state.cvar.Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT_TRUE(callback1.run);
|
|
||||||
ASSERT_TRUE(callback2.run);
|
|
||||||
ASSERT_TRUE(callback3.run);
|
|
||||||
ASSERT_TRUE(callback4.run);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
|
Loading…
Reference in New Issue
Block a user