comms.cpp

1
2
3
#include <planet/comms/signal.hpp>

#include <felspar/io/write.hpp>

planet::comms::internal

 9
10
11
12
13
14
15
16
17
planet::comms::internal::internal(
        felspar::io::warden &w, felspar::source_location const &loc)
: warden{w}, pipe{warden.create_pipe(loc)} {}


std::size_t planet::comms::internal::write(std::span<std::byte const> const b) {
    return felspar::io::write_some(
            pipe.write.native_handle(), b.data(), b.size());
}

planet::comms::signal

23
24
25
26
27
28
29
planet::comms::signal::signal(felspar::io::warden &w) : pipe{w} {}


void planet::comms::signal::send(std::byte const b) {
    std::array<std::byte, 1> const sig{b};
    if (pipe.write(sig) != 1u) { std::terminate(); }
}