Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/include/join/proactor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,9 @@ class join::BasicProactor : public join::EventHandler

/**
* @brief cancel all in-flight operations.
* @param flush submit the cancellations if true.
*/
void cancelAllOperations () noexcept;
void cancelAllOperations (bool flush) noexcept;

/**
* @brief invoke function.
Expand Down
8 changes: 4 additions & 4 deletions core/include/join/proactor_epoll.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ inline void join::BasicProactor::stop (bool sync) noexcept
{
if (isProactorThread ())
{
cancelAllOperations ();
cancelAllOperations (true);
_reactor.stop (false);
return;
}
Expand All @@ -82,7 +82,7 @@ inline void join::BasicProactor::stop (bool sync) noexcept
return;
}

writeCommand ({CommandType::Stop, nullptr, sync, nullptr, nullptr, nullptr});
writeCommand ({CommandType::Stop, nullptr, true, nullptr, nullptr, nullptr});

if (JOIN_LIKELY (sync))
{
Expand Down Expand Up @@ -400,7 +400,7 @@ inline void join::BasicProactor::processCommand (const Command& cmd) noexcept
break;

case CommandType::Stop:
cancelAllOperations ();
cancelAllOperations (cmd.flush);
_reactor.stop (false);
break;

Expand Down Expand Up @@ -586,7 +586,7 @@ inline int join::BasicProactor::cancelOperation (IoOperation& op, [[maybe_unused
// CLASS : BasicProactor
// METHOD : cancelAllOperations
// =========================================================================
inline void join::BasicProactor::cancelAllOperations () noexcept
inline void join::BasicProactor::cancelAllOperations ([[maybe_unused]] bool flush) noexcept
{
for (size_t fd = 0; fd < _readOps.size (); ++fd)
{
Expand Down
17 changes: 9 additions & 8 deletions core/include/join/proactor_uring.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ void join::BasicProactor<IoPolicy>::stop (bool sync) noexcept
if (isProactorThread ())
{
_running.store (false, std::memory_order_release);
cancelAllOperations ();
cancelAllOperations (true);
return;
}

Expand All @@ -190,7 +190,7 @@ void join::BasicProactor<IoPolicy>::stop (bool sync) noexcept
return;
}

writeCommand ({CommandType::Stop, nullptr, sync, nullptr, nullptr, nullptr});
writeCommand ({CommandType::Stop, nullptr, true, nullptr, nullptr, nullptr});

if (JOIN_LIKELY (sync))
{
Expand Down Expand Up @@ -547,11 +547,7 @@ void join::BasicProactor<IoPolicy>::processCommand (const Command& cmd) noexcept

case CommandType::Stop:
_running.store (false, std::memory_order_release);
cancelAllOperations ();
if (JOIN_UNLIKELY (cmd.flush))
{
io_uring_submit (&_ring);
}
cancelAllOperations (cmd.flush);
break;

case CommandType::Flush:
Expand Down Expand Up @@ -720,7 +716,7 @@ int join::BasicProactor<IoPolicy>::cancelOperation (IoOperation& op, bool flush)
// METHOD : cancelAllOperations
// =========================================================================
template <typename IoPolicy>
void join::BasicProactor<IoPolicy>::cancelAllOperations () noexcept
void join::BasicProactor<IoPolicy>::cancelAllOperations (bool flush) noexcept
{
for (IoOperation* op : _pendingOps)
{
Expand All @@ -731,6 +727,11 @@ void join::BasicProactor<IoPolicy>::cancelAllOperations () noexcept
}
cancelOperation (*op, false);
}

if (JOIN_LIKELY (flush))
{
io_uring_submit (&_ring);
}
}

// =========================================================================
Expand Down
Loading