aboutsummaryrefslogtreecommitdiff
path: root/include/cru
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2024-02-12 15:47:31 +0800
committercrupest <crupest@outlook.com>2024-02-14 22:58:11 +0800
commitf9c404510584faab71b9e9d911d9b396b0f420b0 (patch)
treea46280ef09459e1f2997ad4a15f2d4053519e634 /include/cru
parent96ed44c31b92f1492be68c084e8b18972d549743 (diff)
downloadcru-f9c404510584faab71b9e9d911d9b396b0f420b0.tar.gz
cru-f9c404510584faab71b9e9d911d9b396b0f420b0.tar.bz2
cru-f9c404510584faab71b9e9d911d9b396b0f420b0.zip
WORKING: add non-block flag for unix pipe.
Diffstat (limited to 'include/cru')
-rw-r--r--include/cru/common/platform/unix/UnixPipe.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/include/cru/common/platform/unix/UnixPipe.h b/include/cru/common/platform/unix/UnixPipe.h
index 153c52bf..2ea80bde 100644
--- a/include/cru/common/platform/unix/UnixPipe.h
+++ b/include/cru/common/platform/unix/UnixPipe.h
@@ -5,8 +5,17 @@
#ifdef CRU_PLATFORM_UNIX
#include "../../Base.h"
+#include "../../Bitmask.h"
namespace cru::platform::unix {
+namespace details {
+struct UnixPipeFlagTag;
+}
+using UnixPipeFlag = Bitmask<details::UnixPipeFlagTag>;
+struct UnixPipeFlags {
+ constexpr static auto NonBlock = UnixPipeFlag::FromOffset(1);
+};
+
/**
* @brief an unix pipe, commonly for communication of parent process and child
* process.
@@ -32,7 +41,7 @@ class UnixPipe : public Object {
Receive,
};
- explicit UnixPipe(Usage usage);
+ explicit UnixPipe(Usage usage, UnixPipeFlag flags = {});
CRU_DELETE_COPY(UnixPipe)
CRU_DELETE_MOVE(UnixPipe)
@@ -51,6 +60,7 @@ class UnixPipe : public Object {
private:
Usage usage_;
+ UnixPipeFlag flags_;
int read_fd_;
int write_fd_;
};