|
|
@ -36,7 +36,7 @@ class WriteThread { |
|
|
|
// non-parallel informs a follower that its writes have been committed
|
|
|
|
// non-parallel informs a follower that its writes have been committed
|
|
|
|
// (-> STATE_COMPLETED), or when a leader that has chosen to perform
|
|
|
|
// (-> STATE_COMPLETED), or when a leader that has chosen to perform
|
|
|
|
// updates in parallel and needs this Writer to apply its batch (->
|
|
|
|
// updates in parallel and needs this Writer to apply its batch (->
|
|
|
|
// STATE_PARALLEL_FOLLOWER).
|
|
|
|
// STATE_PARALLEL_MEMTABLE_WRITER).
|
|
|
|
STATE_INIT = 1, |
|
|
|
STATE_INIT = 1, |
|
|
|
|
|
|
|
|
|
|
|
// The state used to inform a waiting Writer that it has become the
|
|
|
|
// The state used to inform a waiting Writer that it has become the
|
|
|
@ -129,7 +129,7 @@ class WriteThread { |
|
|
|
WriteGroup* write_group; |
|
|
|
WriteGroup* write_group; |
|
|
|
SequenceNumber sequence; // the sequence number to use for the first key
|
|
|
|
SequenceNumber sequence; // the sequence number to use for the first key
|
|
|
|
Status status; |
|
|
|
Status status; |
|
|
|
Status callback_status; // status returned by callback->Callback()
|
|
|
|
Status callback_status; // status returned by callback->Callback()
|
|
|
|
|
|
|
|
|
|
|
|
std::aligned_storage<sizeof(std::mutex)>::type state_mutex_bytes; |
|
|
|
std::aligned_storage<sizeof(std::mutex)>::type state_mutex_bytes; |
|
|
|
std::aligned_storage<sizeof(std::condition_variable)>::type state_cv_bytes; |
|
|
|
std::aligned_storage<sizeof(std::condition_variable)>::type state_cv_bytes; |
|
|
@ -246,7 +246,7 @@ class WriteThread { |
|
|
|
std::condition_variable& StateCV() { |
|
|
|
std::condition_variable& StateCV() { |
|
|
|
assert(made_waitable); |
|
|
|
assert(made_waitable); |
|
|
|
return *static_cast<std::condition_variable*>( |
|
|
|
return *static_cast<std::condition_variable*>( |
|
|
|
static_cast<void*>(&state_cv_bytes)); |
|
|
|
static_cast<void*>(&state_cv_bytes)); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -273,7 +273,7 @@ class WriteThread { |
|
|
|
// STATE_GROUP_LEADER. If w has been made part of a sequential batch
|
|
|
|
// STATE_GROUP_LEADER. If w has been made part of a sequential batch
|
|
|
|
// group and the leader has performed the write, returns STATE_DONE.
|
|
|
|
// group and the leader has performed the write, returns STATE_DONE.
|
|
|
|
// If w has been made part of a parallel batch group and is responsible
|
|
|
|
// If w has been made part of a parallel batch group and is responsible
|
|
|
|
// for updating the memtable, returns STATE_PARALLEL_FOLLOWER.
|
|
|
|
// for updating the memtable, returns STATE_PARALLEL_MEMTABLE_WRITER.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// The db mutex SHOULD NOT be held when calling this function, because
|
|
|
|
// The db mutex SHOULD NOT be held when calling this function, because
|
|
|
|
// it will block.
|
|
|
|
// it will block.
|
|
|
@ -310,8 +310,8 @@ class WriteThread { |
|
|
|
// the next leader if needed.
|
|
|
|
// the next leader if needed.
|
|
|
|
void ExitAsMemTableWriter(Writer* self, WriteGroup& write_group); |
|
|
|
void ExitAsMemTableWriter(Writer* self, WriteGroup& write_group); |
|
|
|
|
|
|
|
|
|
|
|
// Causes JoinBatchGroup to return STATE_PARALLEL_FOLLOWER for all of the
|
|
|
|
// Causes JoinBatchGroup to return STATE_PARALLEL_MEMTABLE_WRITER for all of
|
|
|
|
// non-leader members of this write batch group. Sets Writer::sequence
|
|
|
|
// the non-leader members of this write batch group. Sets Writer::sequence
|
|
|
|
// before waking them up.
|
|
|
|
// before waking them up.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// WriteGroup* write_group: Extra state used to coordinate the parallel add
|
|
|
|
// WriteGroup* write_group: Extra state used to coordinate the parallel add
|
|
|
|