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

76 lines
2.8 KiB
C++
Raw Normal View History

/***
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;
};
/**
2022-08-02 04:58:00 +00:00
* @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();
/**
2022-08-02 04:58:00 +00:00
* @brief
* @param handleString
* @return
*/
AUKN_SYM AuSPtr<IPCPipe> ImportPipe(const AuString &handleString);
}