io/FileDescriptor: add method SetPipeCapacity()
This commit is contained in:
parent
f535ccf9bf
commit
ebfc83dac5
|
@ -213,6 +213,21 @@ FileDescriptor::DisableCloseOnExec() const noexcept
|
|||
fcntl(fd, F_SETFD, old_flags & ~FD_CLOEXEC);
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
void
|
||||
FileDescriptor::SetPipeCapacity(unsigned capacity) const noexcept
|
||||
{
|
||||
/* the canonical type for buffer sizes is "size_t", but since
|
||||
F_SETPIPE_SZ expects an "int" parameter, "size_t" would
|
||||
have the wrong size; "unsigned" is always the same size as
|
||||
"int", but using a signed integer would suggest that
|
||||
negative values are okay when they're not */
|
||||
fcntl(fd, F_SETPIPE_SZ, capacity);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
UniqueFileDescriptor
|
||||
FileDescriptor::Duplicate() const noexcept
|
||||
{
|
||||
|
|
|
@ -163,6 +163,15 @@ public:
|
|||
*/
|
||||
void DisableCloseOnExec() const noexcept;
|
||||
|
||||
#ifdef __linux__
|
||||
/**
|
||||
* Set the capacity of the pipe.
|
||||
*
|
||||
* This method ignores errors.
|
||||
*/
|
||||
void SetPipeCapacity(unsigned capacity) const noexcept;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Duplicate this file descriptor.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue