2022-04-15 10:01:43 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: IPCPipe.hpp
|
|
|
|
Date: 2022-4-14
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
2022-06-11 23:52:46 +00:00
|
|
|
namespace Aurora::IO::IPC
|
2022-04-15 10:01:43 +00:00
|
|
|
{
|
2022-04-17 12:40:08 +00:00
|
|
|
struct IPCPipe : IExportableIPC
|
2022-04-15 10:01:43 +00:00
|
|
|
{
|
2022-04-17 12:40:08 +00:00
|
|
|
/**
|
|
|
|
* @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.
|
2023-07-29 07:52:33 +00:00
|
|
|
* 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.
|
2022-04-17 12:40:08 +00:00
|
|
|
*/
|
|
|
|
virtual AuSPtr<Loop::ILoopSource> AsReadChannelHasData() = 0;
|
|
|
|
|
|
|
|
/**
|
2023-07-29 07:52:33 +00:00
|
|
|
* @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!
|
2022-04-17 12:40:08 +00:00
|
|
|
*/
|
2022-05-12 08:04:32 +00:00
|
|
|
virtual AuSPtr<IO::IAsyncTransaction> NewAsyncTransaction() = 0;
|
2022-04-17 12:40:08 +00:00
|
|
|
|
2023-07-29 07:52:33 +00:00
|
|
|
/**
|
|
|
|
* @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;
|
|
|
|
|
2022-04-17 12:40:08 +00:00
|
|
|
/**
|
|
|
|
* @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-04-15 10:01:43 +00:00
|
|
|
};
|
2022-04-15 14:46:07 +00:00
|
|
|
|
2022-04-17 12:40:08 +00:00
|
|
|
/**
|
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))
|
2022-04-17 12:40:08 +00:00
|
|
|
* @return
|
|
|
|
*/
|
2022-04-15 10:01:43 +00:00
|
|
|
AUKN_SYM AuSPtr<IPCPipe> NewPipe();
|
2022-04-17 12:40:08 +00:00
|
|
|
|
|
|
|
/**
|
2022-08-02 04:58:00 +00:00
|
|
|
* @brief
|
2022-04-17 12:40:08 +00:00
|
|
|
* @param handleString
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
AUKN_SYM AuSPtr<IPCPipe> ImportPipe(const AuString &handleString);
|
2022-04-15 10:01:43 +00:00
|
|
|
}
|