mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
wpiutil: uv: Add LoopClosing status to Handle (#1647)
Useful for EventLoopRunner to know if a stop is requested, or close is happening for another reason.
This commit is contained in:
committed by
Peter Johnson
parent
7cd6e2e7fa
commit
620bec9cae
@@ -119,6 +119,29 @@ class Handle : public std::enable_shared_from_this<Handle> {
|
||||
*/
|
||||
void Close() noexcept;
|
||||
|
||||
/**
|
||||
* Set if the loop is closing.
|
||||
*
|
||||
* This is set during EventLoopRunner.Stop(), and can be used for other cases
|
||||
* to indicate the loop should be closing. For instance for a uv_walk loop can
|
||||
* use this to close existing handles.
|
||||
*
|
||||
* @param loopClosing true to set the loop currently in closing stages.
|
||||
*/
|
||||
void SetLoopClosing(bool loopClosing) noexcept {
|
||||
m_loopClosing = loopClosing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the loop closing status.
|
||||
*
|
||||
* This can be used from closed() in order to tell if a closing loop is the
|
||||
* reason for the close, or another reason.
|
||||
*
|
||||
* @return true if the loop is closing, otherwise false.
|
||||
*/
|
||||
bool IsLoopClosing() const noexcept { return m_loopClosing; }
|
||||
|
||||
/**
|
||||
* Reference the given handle.
|
||||
*
|
||||
@@ -237,6 +260,7 @@ class Handle : public std::enable_shared_from_this<Handle> {
|
||||
std::shared_ptr<Handle> m_self;
|
||||
uv_handle_t* m_uv_handle;
|
||||
bool m_closed = false;
|
||||
bool m_loopClosing = false;
|
||||
std::function<Buffer(size_t)> m_allocBuf{&Buffer::Allocate};
|
||||
std::function<void(Buffer&)> m_freeBuf{&DefaultFreeBuf};
|
||||
std::shared_ptr<void> m_data;
|
||||
|
||||
Reference in New Issue
Block a user