mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 14:03:58 +00:00
Clean up the io_chain_t interface
This commit is contained in:
parent
371f67f1b5
commit
b00f039489
4 changed files with 12 additions and 18 deletions
|
@ -1106,7 +1106,7 @@ static int exec_subshell_internal(const wcstring &cmd, parser_t &parser, wcstrin
|
||||||
io_buffer_t::create(STDOUT_FILENO, io_chain_t(), is_subcmd ? read_byte_limit : 0));
|
io_buffer_t::create(STDOUT_FILENO, io_chain_t(), is_subcmd ? read_byte_limit : 0));
|
||||||
if (io_buffer.get() != NULL) {
|
if (io_buffer.get() != NULL) {
|
||||||
parser_t &parser = parser_t::principal_parser();
|
parser_t &parser = parser_t::principal_parser();
|
||||||
if (parser.eval(cmd, io_chain_t(io_buffer), SUBST) == 0) {
|
if (parser.eval(cmd, io_chain_t{io_buffer}, SUBST) == 0) {
|
||||||
subcommand_status = proc_get_last_status();
|
subcommand_status = proc_get_last_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -920,7 +920,7 @@ static void test_parser() {
|
||||||
|
|
||||||
static void test_1_cancellation(const wchar_t *src) {
|
static void test_1_cancellation(const wchar_t *src) {
|
||||||
shared_ptr<io_buffer_t> out_buff(io_buffer_t::create(STDOUT_FILENO, io_chain_t()));
|
shared_ptr<io_buffer_t> out_buff(io_buffer_t::create(STDOUT_FILENO, io_chain_t()));
|
||||||
const io_chain_t io_chain(out_buff);
|
const io_chain_t io_chain{out_buff};
|
||||||
pthread_t thread = pthread_self();
|
pthread_t thread = pthread_self();
|
||||||
double delay = 0.25 /* seconds */;
|
double delay = 0.25 /* seconds */;
|
||||||
iothread_perform([=]() {
|
iothread_perform([=]() {
|
||||||
|
|
17
src/io.cpp
17
src/io.cpp
|
@ -120,15 +120,15 @@ void io_chain_t::remove(const shared_ptr<const io_data_t> &element) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void io_chain_t::push_back(const shared_ptr<io_data_t> &element) {
|
void io_chain_t::push_back(shared_ptr<io_data_t> element) {
|
||||||
// Ensure we never push back NULL.
|
// Ensure we never push back NULL.
|
||||||
assert(element.get() != NULL);
|
assert(element.get() != nullptr);
|
||||||
std::vector<shared_ptr<io_data_t> >::push_back(element);
|
std::vector<shared_ptr<io_data_t> >::push_back(std::move(element));
|
||||||
}
|
}
|
||||||
|
|
||||||
void io_chain_t::push_front(const shared_ptr<io_data_t> &element) {
|
void io_chain_t::push_front(shared_ptr<io_data_t> element) {
|
||||||
assert(element.get() != NULL);
|
assert(element.get() != nullptr);
|
||||||
this->insert(this->begin(), element);
|
this->insert(this->begin(), std::move(element));
|
||||||
}
|
}
|
||||||
|
|
||||||
void io_chain_t::append(const io_chain_t &chain) {
|
void io_chain_t::append(const io_chain_t &chain) {
|
||||||
|
@ -253,8 +253,3 @@ shared_ptr<const io_data_t> io_chain_get(const io_chain_t &src, int fd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<io_data_t> io_chain_get(io_chain_t &src, int fd) { return src.get_io_for_fd(fd); }
|
shared_ptr<io_data_t> io_chain_get(io_chain_t &src, int fd) { return src.get_io_for_fd(fd); }
|
||||||
|
|
||||||
io_chain_t::io_chain_t(const shared_ptr<io_data_t> &data)
|
|
||||||
: std::vector<shared_ptr<io_data_t> >(1, data) {}
|
|
||||||
|
|
||||||
io_chain_t::io_chain_t() : std::vector<shared_ptr<io_data_t> >() {}
|
|
||||||
|
|
7
src/io.h
7
src/io.h
|
@ -272,12 +272,11 @@ class io_buffer_t : public io_pipe_t {
|
||||||
|
|
||||||
class io_chain_t : public std::vector<shared_ptr<io_data_t>> {
|
class io_chain_t : public std::vector<shared_ptr<io_data_t>> {
|
||||||
public:
|
public:
|
||||||
io_chain_t();
|
using std::vector<shared_ptr<io_data_t>>::vector;
|
||||||
explicit io_chain_t(const shared_ptr<io_data_t> &);
|
|
||||||
|
|
||||||
void remove(const shared_ptr<const io_data_t> &element);
|
void remove(const shared_ptr<const io_data_t> &element);
|
||||||
void push_back(const shared_ptr<io_data_t> &element);
|
void push_back(shared_ptr<io_data_t> element);
|
||||||
void push_front(const shared_ptr<io_data_t> &element);
|
void push_front(shared_ptr<io_data_t> element);
|
||||||
void append(const io_chain_t &chain);
|
void append(const io_chain_t &chain);
|
||||||
|
|
||||||
shared_ptr<const io_data_t> get_io_for_fd(int fd) const;
|
shared_ptr<const io_data_t> get_io_for_fd(int fd) const;
|
||||||
|
|
Loading…
Reference in a new issue