AuroraRuntime/Include/Aurora/IO/IPC/IPCPipe.hpp

64 lines
2.0 KiB
C++

/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: IPCPipe.hpp
Date: 2022-4-14
Author: Reece
***/
#pragma once
namespace Aurora::IO::IPC
{
struct IPCPipe : IExportableIPC
{
/**
* @brief A loopsource indicating whether or not the pipe has an established client
* @return
*/
virtual AuSPtr<Loop::ILoopSource> AsReadChannelIsOpen() = 0;
/**
* @brief A UNIX loopsource indicating when the pipe has data available.
* Wait semantics will be simlulated on Windows with a constant-step timer.
* @return
* @warning unimplemented on windows. IsSignaled()-as-has-data works nonblocking, though.
*/
virtual AuSPtr<Loop::ILoopSource> AsReadChannelHasData() = 0;
/**
* @brief Returns a shared async file interface to a session between the server
* Undefined behaviour is expected while AsReadChannelIsOpen()->IsSignaled() is false.
* @return
*/
virtual AuSPtr<IO::IAsyncTransaction> NewAsyncTransaction() = 0;
/**
* @brief Reads at least write.length from the outbound stream of the opposite end
* @param nonblocking Wait for data
* @return
*/
virtual bool Read (const Memory::MemoryViewStreamWrite &write, bool nonblocking) = 0;
/**
* @brief Writes at least write.length to the stream on the opposite end
* @param nonblocking Wait for data
* @return
*/
virtual bool Write(const Memory::MemoryViewStreamRead &read) = 0;
};
/**
* @brief Creates a new exclusive, duplex, IPC pipe
*
* (Comparable to Nt: CreateNamedPipeA(nMaxInstances=1, dwOpenMode=PIPE_ACCESS_DUPLEX, dwPipeMode=PIPE_TYPE_BYTE))
* @return
*/
AUKN_SYM AuSPtr<IPCPipe> NewPipe();
/**
* @brief
* @param handleString
* @return
*/
AUKN_SYM AuSPtr<IPCPipe> ImportPipe(const AuString &handleString);
}