Skip to content

Commit

Permalink
nixd: add non null getters for StreamProc
Browse files Browse the repository at this point in the history
  • Loading branch information
inclyc committed Apr 17, 2024
1 parent 4801001 commit d4cef26
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions nixd/include/nixd/Support/StreamProc.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,27 @@
namespace nixd {

struct StreamProc {
private:
std::unique_ptr<util::PipedProc> Proc;
std::unique_ptr<llvm::raw_fd_ostream> Stream;

public:
/// \brief Launch a streamed process with \p Action.
///
/// The value returned by \p Action will be interpreted as process's exit
/// value.
StreamProc(const std::function<int()> &Action);

[[nodiscard]] llvm::raw_fd_ostream &stream() const {
assert(Stream);
return *Stream;
}

[[nodiscard]] util::PipedProc &proc() const {
assert(Proc);
return *Proc;
}

[[nodiscard]] std::unique_ptr<lspserver::InboundPort> mkIn() const;

[[nodiscard]] std::unique_ptr<lspserver::OutboundPort> mkOut() const;
Expand Down
2 changes: 1 addition & 1 deletion nixd/lib/Eval/AttrSetClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ AttrSetClientProc::AttrSetClientProc(const std::function<int()> &Action)
Input([this]() { Client.run(); }) {}

AttrSetClient *AttrSetClientProc::client() {
if (!kill(Proc.Proc->PID, 0))
if (!kill(Proc.proc().PID, 0))
return &Client;
return nullptr;
}

0 comments on commit d4cef26

Please sign in to comment.