[+] Added WriteEoS
[*] Fix two build issues (missing = 0 in vtbl and messed up macros)
This commit is contained in:
parent
8fe1ab04a5
commit
235225ec9d
@ -12,5 +12,6 @@ namespace Aurora::IO::FS
|
|||||||
virtual bool Write(const Memory::MemoryViewStreamRead ¶meters) = 0;
|
virtual bool Write(const Memory::MemoryViewStreamRead ¶meters) = 0;
|
||||||
virtual void Close() = 0;
|
virtual void Close() = 0;
|
||||||
virtual void Flush() = 0;
|
virtual void Flush() = 0;
|
||||||
|
virtual void WriteEoS() = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -34,7 +34,7 @@ namespace Aurora::Processes
|
|||||||
virtual bool TryKill() = 0;
|
virtual bool TryKill() = 0;
|
||||||
|
|
||||||
virtual bool Read(bool error, void *buffer, AuUInt32 &len) = 0;
|
virtual bool Read(bool error, void *buffer, AuUInt32 &len) = 0;
|
||||||
virtual bool Read(void *buffer, AuUInt32 &len, bool errorStream = false, bool nonblock = true);
|
virtual bool Read(void *buffer, AuUInt32 &len, bool errorStream = false, bool nonblock = true) = 0;
|
||||||
virtual bool Write(const void *buffer, AuUInt32 len) = 0;
|
virtual bool Write(const void *buffer, AuUInt32 len) = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -85,11 +85,26 @@ namespace Aurora::Threading
|
|||||||
std::conditional_t<std::is_pointer_v<T>, T, T*> annoying_;
|
std::conditional_t<std::is_pointer_v<T>, T, T*> annoying_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define AU_TRY_LOCK_GUARD(variable) Aurora::Threading::TryLockGuard<decltype(variable)> AU_CONCAT(__stack_lock, __COUNTER__) (variable);
|
|
||||||
#define AU_TRY_LOCK_GUARD_RET_NAMED(variable, value, name) Aurora::Threading::TryLockGuard<decltype(variable)> name (variable); if (!(name.Locked())) return value;
|
// Named try-lock guard. Use when you wish to poll ::Locked(), otherwise use the auto-return macros
|
||||||
#define AU_TRY_LOCK_GUARD_RET(variable, value, counter) AU_TRY_LOCK_GUARD_RET_NAMED(variable, value, AU_CONCAT(__stack_lock, counter))
|
// There is no point in using anonymous lock handles w/o checking the lock state or auto-returning
|
||||||
#define AU_TRY_LOCK_GUARD_RET_VAL(variable, value) AU_TRY_LOCK_GUARD_RET_NAMED(variable, value, AU_WHAT(__COUNTER__))
|
// Where variable = an iwaitable-like interface reference, pointer, or shared pointer; value = reference to a boolean
|
||||||
|
// name = name of handle variable
|
||||||
|
#define AU_TRY_LOCK_GUARD_NAMED(variable, name) Aurora::Threading::TryLockGuard<decltype(variable)> name(variable);
|
||||||
|
|
||||||
|
/// @hideinitializer
|
||||||
|
#define AU_TRY_LOCK_GUARD_RET_NAMED(variable, value, name) AU_TRY_LOCK_GUARD_NAMED(variable, name) if (!(name.Locked())) return value;
|
||||||
|
|
||||||
|
/// @hideinitializer
|
||||||
|
#define AU_TRY_LOCK_GUARD_RET_COUNTERVAL(variable, value, counter) AU_TRY_LOCK_GUARD_RET_NAMED(variable, value, AU_CONCAT(__stack_lock, counter))
|
||||||
|
|
||||||
|
// where variable = an iwaitable-like interface reference, pointer, or shared pointer; value = reference to a boolean
|
||||||
|
// value = failure return object
|
||||||
|
#define AU_TRY_LOCK_GUARD_RET_VAL(variable, value) AU_TRY_LOCK_GUARD_RET_COUNTERVAL(variable, value, AU_WHAT(__COUNTER__))
|
||||||
|
|
||||||
|
// where variable = an iwaitable-like interface reference, pointer, or shared pointer
|
||||||
#define AU_TRY_LOCK_GUARD_RET_DEF(variable) AU_TRY_LOCK_GUARD_RET_VAL(variable, {})
|
#define AU_TRY_LOCK_GUARD_RET_DEF(variable) AU_TRY_LOCK_GUARD_RET_VAL(variable, {})
|
||||||
|
|
||||||
|
// where variable = an iwaitable-like interface reference, pointer
|
||||||
#define AU_TRY_LOCK_GUARD_RET(variable) AU_TRY_LOCK_GUARD_RET_VAL(variable, )
|
#define AU_TRY_LOCK_GUARD_RET(variable) AU_TRY_LOCK_GUARD_RET_VAL(variable, )
|
||||||
#define AU_TRY_LOCK_GUARD_NAMED(variable, name) AU_TRY_LOCK_GUARD_RET_NAMED(variable, , name)
|
|
||||||
}
|
}
|
@ -228,7 +228,7 @@ namespace Aurora::IO::FS
|
|||||||
|
|
||||||
bool NtAsyncFileTransaction::Complete()
|
bool NtAsyncFileTransaction::Complete()
|
||||||
{
|
{
|
||||||
auto ret = WaitForSingleObject(this->event_, 0);
|
auto ret = WaitForSingleObjectEx(this->event_, 0, true);
|
||||||
if (ret == WAIT_OBJECT_0)
|
if (ret == WAIT_OBJECT_0)
|
||||||
{
|
{
|
||||||
DispatchCb();
|
DispatchCb();
|
||||||
@ -251,7 +251,7 @@ namespace Aurora::IO::FS
|
|||||||
|
|
||||||
bool NtAsyncFileTransaction::Wait(AuUInt32 timeout)
|
bool NtAsyncFileTransaction::Wait(AuUInt32 timeout)
|
||||||
{
|
{
|
||||||
auto ret = WaitForSingleObject(this->event_, timeout ? timeout : INFINITE);
|
auto ret = WaitForSingleObjectEx(this->event_, timeout ? timeout : INFINITE, true);
|
||||||
if (ret == WAIT_OBJECT_0)
|
if (ret == WAIT_OBJECT_0)
|
||||||
{
|
{
|
||||||
DispatchCb();
|
DispatchCb();
|
||||||
@ -302,7 +302,7 @@ namespace Aurora::IO::FS
|
|||||||
handles.push_back(std::static_pointer_cast<NtAsyncFileTransaction>(file)->GetHandle());
|
handles.push_back(std::static_pointer_cast<NtAsyncFileTransaction>(file)->GetHandle());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ret = WaitForMultipleObjects(handles.size(), handles.data(), false, timeout ? timeout : INFINITE);
|
auto ret = WaitForMultipleObjectsEx(handles.size(), handles.data(), false, timeout ? timeout : INFINITE, TRUE);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
for (const auto &file : files)
|
for (const auto &file : files)
|
||||||
|
@ -70,6 +70,12 @@ namespace Aurora::IO::FS
|
|||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void WriteEoS() override
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
virtual void GoToEof() = 0;
|
virtual void GoToEof() = 0;
|
||||||
protected:
|
protected:
|
||||||
AuUInt64 offset_ = 0;
|
AuUInt64 offset_ = 0;
|
||||||
|
@ -105,7 +105,7 @@ namespace Aurora::IO::FS
|
|||||||
|
|
||||||
int blockSize = std::min(kFileCopyBlock, length);
|
int blockSize = std::min(kFileCopyBlock, length);
|
||||||
|
|
||||||
if (!::ReadFile(handle_, &reinterpret_cast<char *>(parameters.ptr)[offset], blockSize, &read, NULL))
|
if (!::ReadFile(handle_, reinterpret_cast<char *>(parameters.ptr) + offset, blockSize, &read, NULL))
|
||||||
{
|
{
|
||||||
LogWarn("ReadFile IO Error: 0x{:x}, {}", GetLastError(), path_);
|
LogWarn("ReadFile IO Error: 0x{:x}, {}", GetLastError(), path_);
|
||||||
SysPushErrorIO();
|
SysPushErrorIO();
|
||||||
@ -146,7 +146,7 @@ namespace Aurora::IO::FS
|
|||||||
|
|
||||||
int blockSize = std::min(kFileCopyBlock, length);
|
int blockSize = std::min(kFileCopyBlock, length);
|
||||||
|
|
||||||
if (!::WriteFile(handle_, &reinterpret_cast<const char *>(parameters.ptr)[offset], blockSize, &written, NULL))
|
if (!::WriteFile(handle_, reinterpret_cast<const char *>(parameters.ptr) + offset, blockSize, &written, NULL))
|
||||||
{
|
{
|
||||||
LogWarn("WriteFileEx IO Error: 0x{:x}, {}", GetLastError(), path_);
|
LogWarn("WriteFileEx IO Error: 0x{:x}, {}", GetLastError(), path_);
|
||||||
SysPushErrorIO();
|
SysPushErrorIO();
|
||||||
@ -173,6 +173,17 @@ namespace Aurora::IO::FS
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WinFileStream::WriteEoS()
|
||||||
|
{
|
||||||
|
if (handle_ == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
SysPushErrorUninitialized();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetEndOfFile(handle_);
|
||||||
|
}
|
||||||
|
|
||||||
void WinFileStream::Close()
|
void WinFileStream::Close()
|
||||||
{
|
{
|
||||||
AuWin32CloseHandle(handle_);
|
AuWin32CloseHandle(handle_);
|
||||||
|
@ -25,6 +25,7 @@ namespace Aurora::IO::FS
|
|||||||
bool Write(const Memory::MemoryViewStreamRead & parameters) override;
|
bool Write(const Memory::MemoryViewStreamRead & parameters) override;
|
||||||
void Close() override;
|
void Close() override;
|
||||||
void Flush() override;
|
void Flush() override;
|
||||||
|
void WriteEoS() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
namespace Aurora::Threading
|
namespace Aurora::Threading
|
||||||
{
|
{
|
||||||
static inline void YieldToSharedCore(long spin)
|
static void YieldToSharedCore(long spin)
|
||||||
{
|
{
|
||||||
int loops = (1 << spin);
|
int loops = (1 << spin);
|
||||||
while (loops > 0)
|
while (loops > 0)
|
||||||
@ -315,7 +315,7 @@ namespace Aurora::Threading
|
|||||||
return reinterpret_cast<HANDLE>(handle);
|
return reinterpret_cast<HANDLE>(handle);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto status = WaitForMultipleObjects(winWaitables.size(), winWaitables.data(), TRUE, timeoutMs ? timeoutMs : INFINITE);
|
auto status = WaitForMultipleObjectsEx(winWaitables.size(), winWaitables.data(), TRUE, timeoutMs ? timeoutMs : INFINITE, true);
|
||||||
SysAssert(status != WAIT_FAILED, "Internal Win32 Error {}", GetLastError());
|
SysAssert(status != WAIT_FAILED, "Internal Win32 Error {}", GetLastError());
|
||||||
|
|
||||||
if (status == WAIT_TIMEOUT)
|
if (status == WAIT_TIMEOUT)
|
||||||
|
Loading…
Reference in New Issue
Block a user