2022-04-13 11:00:35 +00:00
/***
Copyright ( C ) 2022 J Reece Wilson ( a / k / a " Reece " ) . All rights reserved .
File : IOSubmit . Linux . hpp
Date : 2022 - 4 - 12
Author : Reece
Note : I want APCs , overlapped , and event based IO on Linux . Gib .
* * */
# pragma once
# include <linux/aio_abi.h>
namespace Aurora : : IO : : UNIX
{
struct ASubmittable
{
2022-08-09 06:48:29 +00:00
ASubmittable ( ) ;
~ ASubmittable ( ) ;
2022-04-13 11:00:35 +00:00
virtual void LIOS_Process ( AuUInt32 read , bool failure , int err , bool mark ) = 0 ;
void LIOS_SendProcess ( AuUInt32 read , bool failure , int err , bool mark = false ) ;
void LIOS_Init ( const AuSPtr < void > & pin ) ;
void LIOS_Reset ( ) ;
2023-12-24 05:41:03 +00:00
bool LIOS_Cancel ( ) ;
2022-04-13 11:00:35 +00:00
bool HasState ( ) ;
2024-07-13 15:34:44 +00:00
void SetMemory ( const AuMemoryViewRead & view ) ;
void SetMemory ( const AuMemoryViewWrite & view ) ;
2022-04-13 11:00:35 +00:00
AuUInt64 GetData ( ) ;
AuUInt64 GetBuf ( ) ;
AuUInt GetBufLength ( ) ;
iocb & GetIOCB ( ) ;
2022-08-09 06:48:29 +00:00
int GetOrCreateFdPollForBlockingRead ( int fd ) ;
// Hack for blocking reads
bool bIsReadPending { } ;
2024-03-04 11:55:54 +00:00
bool bIsWritePending { } ;
2022-08-09 06:48:29 +00:00
AuUInt64 offset2 { } ;
int fd2 { } ;
AuLoop : : ILSEvent * optEvent2 { } ;
2023-12-24 06:22:58 +00:00
aio_context_t abortContext { } ;
2022-08-09 06:48:29 +00:00
2024-02-23 12:44:43 +00:00
// TODO:
AuSPtr < void > pin_ ;
AuSPtr < void > memPin_ ;
2024-07-13 15:34:44 +00:00
AuMemoryViewRead readView ;
AuMemoryViewWrite writeView ;
2022-04-13 11:00:35 +00:00
private :
AuUInt64 dataPtr_ { } ;
AuUInt dataLen_ { } ;
2022-08-09 06:48:29 +00:00
int tempEPoll { - 1 } ;
2022-04-13 11:00:35 +00:00
iocb cb { } ;
} ;
// Yield/Wait shims
bool LinuxOverlappedWaitForOne ( AuUInt32 timeout , AuUInt read , AuUInt write , bool & bReadTriggered , bool & bWriteTriggered ) ;
bool LinuxOverlappedWaitForAtleastOne ( AuUInt32 timeout , const AuList < AuUInt > & handles , const AuList < AuUInt > & handlesWrite , AuUInt & one , AuUInt & two ) ;
bool LinuxOverlappedPoll ( AuUInt32 timeout ) ;
int LinuxOverlappedEpollShim ( int epfd , struct epoll_event * events ,
int maxevents , int timeout ) ;
2022-08-02 04:52:17 +00:00
bool LinuxOverlappedYield ( ) ;
2022-04-13 11:00:35 +00:00
// Work queue
2022-08-09 06:48:29 +00:00
bool LinuxOverlappedSubmitRead ( int fd , AuUInt offset , ASubmittable * context , AuLoop : : ILSEvent * optEvent , bool bWaitForRead = false /* use on unsupported blocking interfaces. costs an epoll to work around >current< limitiations in io_submit*/ ) ;
2022-04-13 11:00:35 +00:00
bool LinuxOverlappedSubmitWrite ( int fd , AuUInt offset , ASubmittable * context , AuLoop : : ILSEvent * optEvent ) ;
// TODO: Stream copy operations
// Bookkeeping
bool SendIOBuffers ( ) ;
}