AuroraRuntime/Include/Aurora/IO/IPC/IPCPipe.hpp
Jamie Reece Wilson bd69ad6739 [+] IPCPipe::ToFileStream
[+] IPCPipe::ToStreamReader
[+] IPCPipe::ToStreamWriter
2023-10-20 16:33:18 +01:00

101 lines
3.3 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 simulated on Windows with a constant-step timer.
* @warning waiting is unimplemented on windows. IsSignaled()-as-has-data works though.
* @warning you should therefore not poll against 'has data'.
* @warning use ::NewAsyncTransaction() to read from the duplex pipe instead.
*/
virtual AuSPtr<Loop::ILoopSource> AsReadChannelHasData() = 0;
/**
* @brief Returns a shared async file interface to a full-duplex pipe between both ends
*
* Undefined behaviour is expected while AsReadChannelIsOpen()->IsSignaled() is false
* You must only start reading once you have established readiness of the connection!
* You must poll against the AsReadChannelIsOpen() source first!
*/
virtual AuSPtr<IO::IAsyncTransaction> NewAsyncTransaction() = 0;
/**
* @brief Returns a shared blocking file handle to a full-duplex pipe between both ends
*
* Undefined behaviour is expected while AsReadChannelIsOpen()->IsSignaled() is false
* You must only start reading once you have established readiness of the connection!
* You must poll against the AsReadChannelIsOpen() source first!
*/
virtual AuSPtr<IO::IIOHandle> GetCurrentSharedDuplexHandles() = 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
* @return
*/
virtual AuSPtr<IO::FS::IFileStream> ToFileStream() = 0;
/**
* @brief
* @return
*/
virtual AuSPtr<IStreamReader> ToStreamReader() = 0;
/**
* @brief
* @return
*/
virtual AuSPtr<IStreamWriter> ToStreamWriter() = 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 uBytesLength
* @return
*/
AUKN_SYM AuSPtr<IPCPipe> NewPipeEx(AuUInt32 uBytesLength);
/**
* @brief
* @param handleString
* @return
*/
AUKN_SYM AuSPtr<IPCPipe> ImportPipe(const AuString &handleString);
}