.gitignore: ignore local vscode workspace settings file
[lttng-tools.git] / src / common / pipe.hpp
index d46e65d6833a32b97228e7a76573aaca829e2b64..5249061f865ba12a66b842f614abf6316d2b5a3a 100644 (file)
@@ -8,8 +8,10 @@
 #ifndef LTTNG_PIPE_H
 #define LTTNG_PIPE_H
 
-#include <pthread.h>
 #include <common/macros.hpp>
+#include <common/make-unique-wrapper.hpp>
+
+#include <pthread.h>
 #include <sys/types.h>
 
 enum lttng_pipe_state {
@@ -17,7 +19,15 @@ enum lttng_pipe_state {
        LTTNG_PIPE_STATE_CLOSED = 2,
 };
 
+/* Close both side of pipe. */
+int lttng_pipe_close(struct lttng_pipe *pipe);
+void lttng_pipe_destroy(struct lttng_pipe *pipe);
+
 struct lttng_pipe {
+       using uptr = std::unique_ptr<
+               lttng_pipe,
+               lttng::memory::create_deleter_class<lttng_pipe, lttng_pipe_destroy>::deleter>;
+
        /* Read: 0, Write: 1. */
        int fd[2];
        /*
@@ -65,17 +75,12 @@ static inline int lttng_pipe_get_writefd(const struct lttng_pipe *pipe)
 }
 
 struct lttng_pipe *lttng_pipe_open(int flags);
-struct lttng_pipe *lttng_pipe_named_open(const char *path, mode_t mode,
-               int flags);
+struct lttng_pipe *lttng_pipe_named_open(const char *path, mode_t mode, int flags);
 int lttng_pipe_write_close(struct lttng_pipe *pipe);
 int lttng_pipe_read_close(struct lttng_pipe *pipe);
-/* Close both side of pipe. */
-int lttng_pipe_close(struct lttng_pipe *pipe);
-void lttng_pipe_destroy(struct lttng_pipe *pipe);
 
 ssize_t lttng_pipe_read(struct lttng_pipe *pipe, void *buf, size_t count);
-ssize_t lttng_pipe_write(struct lttng_pipe *pipe, const void *buf,
-               size_t count);
+ssize_t lttng_pipe_write(struct lttng_pipe *pipe, const void *buf, size_t count);
 /* Returns and releases the read end of the pipe. */
 int lttng_pipe_release_readfd(struct lttng_pipe *pipe);
 /* Returns and releases the write end of the pipe. */
This page took 0.023809 seconds and 4 git commands to generate.