Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
Signed-off-by: gengliqi <gengliqiii@gmail.com>
  • Loading branch information
gengliqi committed Jul 7, 2022
1 parent 99dc4b9 commit fc8a972
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions dbms/src/Common/MPMCQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,23 +258,22 @@ class MPMCQueue
}

template <bool need_wait>
bool popObj(T & res, const TimePoint * deadline = nullptr)
bool popObj(T & res, [[maybe_unused]] const TimePoint * deadline = nullptr)
{
#ifdef __APPLE__
WaitingNode node;
#else
thread_local WaitingNode node;
#endif
{
/// read_pos < write_pos means the queue isn't empty
auto pred = [&] {
return read_pos < write_pos || !isNormal();
};

std::unique_lock lock(mu);

if constexpr (need_wait)
{
/// read_pos < write_pos means the queue isn't empty
auto pred = [&] {
return read_pos < write_pos || !isNormal();
};
wait(lock, reader_head, node, pred, deadline);
}

Expand All @@ -301,21 +300,20 @@ class MPMCQueue
}

template <bool need_wait, typename F>
bool assignObj(const TimePoint * deadline, F && assigner)
bool assignObj([[maybe_unused]] const TimePoint * deadline, F && assigner)
{
#ifdef __APPLE__
WaitingNode node;
#else
thread_local WaitingNode node;
#endif
auto pred = [&] {
return write_pos - read_pos < capacity || !isNormal();
};

std::unique_lock lock(mu);

if constexpr (need_wait)
{
auto pred = [&] {
return write_pos - read_pos < capacity || !isNormal();
};
wait(lock, writer_head, node, pred, deadline);
}

Expand Down

0 comments on commit fc8a972

Please sign in to comment.