Merge 6d10ee9e7367460bfdc44805ac77ee01765e0969 into 3afe581c1f22f106d59cf54b9b65251e6c554671

This commit is contained in:
Jan Christoph Uhde 2025-03-30 16:54:10 +03:00 committed by GitHub
commit 830e538ec6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -169,7 +169,7 @@ using env_vector_t = std::vector<env_char_t>;
namespace util namespace util
{ {
template <typename R> template <typename R>
inline bool is_ready(std::shared_future<R> const &f) bool is_ready(std::shared_future<R> const &f)
{ {
return f.wait_for(std::chrono::seconds(0)) == std::future_status::ready; return f.wait_for(std::chrono::seconds(0)) == std::future_status::ready;
} }
@ -408,7 +408,7 @@ namespace util
* to be split. Default constructed to ' '(space) and '\t'(tab) * to be split. Default constructed to ' '(space) and '\t'(tab)
* [out] vector<string> : Vector of strings split at deleimiter. * [out] vector<string> : Vector of strings split at deleimiter.
*/ */
static inline std::vector<std::string> inline std::vector<std::string>
split(const std::string& str, const std::string& delims=" \t") split(const std::string& str, const std::string& delims=" \t")
{ {
std::vector<std::string> res; std::vector<std::string> res;
@ -438,7 +438,7 @@ namespace util
* Default constructed to ' ' (space). * Default constructed to ' ' (space).
* [out] string: Joined string. * [out] string: Joined string.
*/ */
static inline inline
std::string join(const std::vector<std::string>& vec, std::string join(const std::vector<std::string>& vec,
const std::string& sep = " ") const std::string& sep = " ")
{ {
@ -459,7 +459,7 @@ namespace util
* [in] set : If 'true', set FD_CLOEXEC. * [in] set : If 'true', set FD_CLOEXEC.
* If 'false' unset FD_CLOEXEC. * If 'false' unset FD_CLOEXEC.
*/ */
static inline inline
void set_clo_on_exec(int fd, bool set = true) void set_clo_on_exec(int fd, bool set = true)
{ {
int flags = fcntl(fd, F_GETFD, 0); int flags = fcntl(fd, F_GETFD, 0);
@ -479,7 +479,7 @@ namespace util
* First element of pair is the read descriptor of pipe. * First element of pair is the read descriptor of pipe.
* Second element is the write descriptor of pipe. * Second element is the write descriptor of pipe.
*/ */
static inline inline
std::pair<int, int> pipe_cloexec() noexcept(false) std::pair<int, int> pipe_cloexec() noexcept(false)
{ {
int pipe_fds[2]; int pipe_fds[2];
@ -507,7 +507,7 @@ namespace util
* `buf` to `fd`. * `buf` to `fd`.
* [out] int : Number of bytes written or -1 in case of failure. * [out] int : Number of bytes written or -1 in case of failure.
*/ */
static inline inline
int write_n(int fd, const char* buf, size_t length) int write_n(int fd, const char* buf, size_t length)
{ {
size_t nwritten = 0; size_t nwritten = 0;
@ -534,7 +534,7 @@ namespace util
* will retry to read from `fd`, but only till the EINTR counter * will retry to read from `fd`, but only till the EINTR counter
* reaches 50 after which it will return with whatever data it read. * reaches 50 after which it will return with whatever data it read.
*/ */
static inline inline
int read_atmost_n(FILE* fp, char* buf, size_t read_upto) int read_atmost_n(FILE* fp, char* buf, size_t read_upto)
{ {
#ifdef __USING_WINDOWS__ #ifdef __USING_WINDOWS__
@ -576,7 +576,7 @@ namespace util
* NOTE: `class Buffer` is a exposed public class. See below. * NOTE: `class Buffer` is a exposed public class. See below.
*/ */
static inline int read_all(FILE* fp, std::vector<char>& buf) inline int read_all(FILE* fp, std::vector<char>& buf)
{ {
auto buffer = buf.data(); auto buffer = buf.data();
int total_bytes_read = 0; int total_bytes_read = 0;
@ -624,7 +624,7 @@ namespace util
* NOTE: This is a blocking call as in, it will loop * NOTE: This is a blocking call as in, it will loop
* till the child is exited. * till the child is exited.
*/ */
static inline inline
std::pair<int, int> wait_for_child_exit(int pid) std::pair<int, int> wait_for_child_exit(int pid)
{ {
int status = 0; int status = 0;
@ -1374,7 +1374,7 @@ inline void Popen::init_args() {
} }
template <typename F, typename... Args> template <typename F, typename... Args>
inline void Popen::init_args(F&& farg, Args&&... args) void Popen::init_args(F&& farg, Args&&... args)
{ {
detail::ArgumentDeducer argd(this); detail::ArgumentDeducer argd(this);
argd.set_option(std::forward<F>(farg)); argd.set_option(std::forward<F>(farg));
@ -2009,13 +2009,13 @@ namespace detail
return Popen(std::forward<F>(farg), std::forward<Args>(args)...).wait(); return Popen(std::forward<F>(farg), std::forward<Args>(args)...).wait();
} }
static inline void pipeline_impl(std::vector<Popen>& cmds) inline void pipeline_impl(std::vector<Popen>& cmds)
{ {
/* EMPTY IMPL */ /* EMPTY IMPL */
} }
template<typename... Args> template<typename... Args>
static inline void pipeline_impl(std::vector<Popen>& cmds, void pipeline_impl(std::vector<Popen>& cmds,
const std::string& cmd, const std::string& cmd,
Args&&... args) Args&&... args)
{ {