Preapre codebase for FileRequest compiletime improvements (#6192)
* Preapre codebase for FileRequest compiletime improvements This is preparing grounds for the next PR that will contain the 'meat' of the changes. Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Remove spurious newline. Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com>
This commit is contained in:
@@ -199,7 +199,7 @@ namespace AzFramework
|
||||
{
|
||||
activeFile = &m_filePaths[m_activeCacheSlot];
|
||||
}
|
||||
|
||||
|
||||
// Estimate requests in this stack entry.
|
||||
for (FileRequest* request : m_pendingRequests)
|
||||
{
|
||||
@@ -279,7 +279,7 @@ namespace AzFramework
|
||||
using namespace AZ::IO;
|
||||
|
||||
AZ_PROFILE_FUNCTION(AzCore);
|
||||
|
||||
|
||||
auto data = AZStd::get_if<FileRequest::ReadData>(&request->GetCommand());
|
||||
AZ_Assert(data, "Request doing reading in the RemoteStorageDrive didn't contain read data.");
|
||||
|
||||
@@ -292,7 +292,7 @@ namespace AzFramework
|
||||
file = m_fileHandles[cacheIndex];
|
||||
m_fileLastUsed[cacheIndex] = AZStd::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
||||
|
||||
// If the file is not open, eject the oldest entry from the cache and open the file for reading.
|
||||
if (file == InvalidHandle)
|
||||
{
|
||||
@@ -325,7 +325,7 @@ namespace AzFramework
|
||||
}
|
||||
m_activeCacheSlot = cacheIndex;
|
||||
|
||||
AZ_Assert(file != InvalidHandle,
|
||||
AZ_Assert(file != InvalidHandle,
|
||||
"While searching for file '%s' RemoteStorageDevice::ReadFile encountered a problem that wasn't reported.", data->m_path.GetRelativePath());
|
||||
{
|
||||
TIMED_AVERAGE_WINDOW_SCOPE(m_readTimeAverage);
|
||||
@@ -357,7 +357,7 @@ namespace AzFramework
|
||||
}
|
||||
}
|
||||
m_readSizeAverage.PushEntry(data->m_size);
|
||||
|
||||
|
||||
request->SetStatus(IStreamerTypes::RequestStatus::Completed);
|
||||
m_context->MarkRequestAsCompleted(request);
|
||||
}
|
||||
@@ -507,7 +507,7 @@ namespace AzFramework
|
||||
using namespace AZ::IO;
|
||||
|
||||
using DoubleSeconds = AZStd::chrono::duration<double>;
|
||||
|
||||
|
||||
double totalBytesReadMB = m_readSizeAverage.GetTotal() / (1024.0 * 1024.0);
|
||||
double totalReadTimeSec = AZStd::chrono::duration_cast<DoubleSeconds>(m_readTimeAverage.GetTotal()).count();
|
||||
if (m_readSizeAverage.GetTotal() > 1) // A default is always added.
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace AzFramework
|
||||
|
||||
protected:
|
||||
static constexpr AZ::s32 s_maxRequests = 1;
|
||||
|
||||
|
||||
void ReadFile(AZ::IO::FileRequest* request);
|
||||
bool CancelRequest(AZ::IO::FileRequest* cancelRequest, AZ::IO::FileRequestPtr& target);
|
||||
void FileExistsRequest(AZ::IO::FileRequest* request);
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace AzFramework
|
||||
AZ::Outcome<void, AZStd::string> CompileScript(ScriptCompileRequest& request, AZ::ScriptContext& scriptContext)
|
||||
{
|
||||
AZ_TracePrintf(request.m_errorWindow.data(), "Starting script compile.\n");
|
||||
|
||||
|
||||
AZStd::string debugName = "@";
|
||||
debugName += request.m_sourceFile;
|
||||
AZStd::to_lower(debugName.begin(), debugName.end());
|
||||
@@ -180,14 +180,14 @@ namespace AzFramework
|
||||
{
|
||||
using namespace AZ::IO;
|
||||
FileIOStream outputStream;
|
||||
|
||||
|
||||
if (!outputStream.Open(request.m_destPath.c_str(), OpenMode::ModeWrite | OpenMode::ModeBinary))
|
||||
{
|
||||
return AZ::Failure(AZStd::string("Failed to open output file %s", request.m_destPath.data()));
|
||||
}
|
||||
|
||||
request.m_output = &outputStream;
|
||||
|
||||
|
||||
if (writeAssetInfo)
|
||||
{
|
||||
if (request.m_prewriteCallback)
|
||||
@@ -292,7 +292,7 @@ namespace AzFramework
|
||||
|
||||
namespace Internal
|
||||
{
|
||||
|
||||
|
||||
AZStd::string PrintLuaValue(lua_State* lua, int stackIdx, int depth = 0)
|
||||
{
|
||||
constexpr int MaxDepth = 4;
|
||||
@@ -302,7 +302,7 @@ namespace AzFramework
|
||||
}
|
||||
|
||||
const int elementType = lua_type(lua, stackIdx);
|
||||
|
||||
|
||||
switch (elementType)
|
||||
{
|
||||
case LUA_TSTRING:
|
||||
@@ -347,7 +347,7 @@ namespace AzFramework
|
||||
{
|
||||
keyValuePairs += " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tableStr += keyValuePairs.length() < 1024 ? keyValuePairs : AZStd::string::format("too many keys (%i)!", keyCount);
|
||||
@@ -891,18 +891,18 @@ namespace AzFramework
|
||||
// This is the root table (properties) it will be used as properties for all sub tables
|
||||
// ScriptComponents can share the same lua script asset, but each instance's Properties table needs to be unique.
|
||||
// This way the script can change a property at runtime and not affect the other ScriptComponents which are using the same script.
|
||||
// For normal properties we will create new variable instances, but NetSynched variables aren't stored in Lua, and instead
|
||||
// For normal properties we will create new variable instances, but NetSynched variables aren't stored in Lua, and instead
|
||||
// are retrieved using the __index and __newIndex metamethods.
|
||||
// Ensure that this instance of Properties table has the proper __index and __newIndex metamethods.
|
||||
lua_newtable(lua); // This new table will become the Properties instance metatable. Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {}
|
||||
lua_newtable(lua); // This new table will become the Properties instance metatable. Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {}
|
||||
lua_pushliteral(lua, "__index"); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {} __index
|
||||
lua_pushcclosure(lua, &Internal::Properties__Index, 0); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {} __index function
|
||||
lua_rawset(lua, -3); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {__index=Internal::Properties__Index}
|
||||
lua_rawset(lua, -3); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {__index=Internal::Properties__Index}
|
||||
|
||||
lua_pushliteral(lua, "__newindex");
|
||||
lua_pushcclosure(lua, &Internal::Properties__NewIndex, 0);
|
||||
lua_rawset(lua, -3); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {__index=Internal::Properties__Index __newindex=Internal::Properties__NewIndex}
|
||||
lua_setmetatable(lua, -2); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {Meta{__index=Internal::Properties__Index __newindex=Internal::Properties__NewIndex} }
|
||||
lua_rawset(lua, -3); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {__index=Internal::Properties__Index __newindex=Internal::Properties__NewIndex}
|
||||
lua_setmetatable(lua, -2); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {Meta{__index=Internal::Properties__Index __newindex=Internal::Properties__NewIndex} }
|
||||
|
||||
metatableIndex = lua_gettop(lua); // This will be the metatable for all subtables
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user