/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #pragma once #include #include #include #include #include #include #include "RemoteFileIO.h" namespace AZ { namespace IO { class RemoteStorageDrive : public StreamStackEntry { public: explicit RemoteStorageDrive(u32 maxFileHandles); ~RemoteStorageDrive() override; void PrepareRequest(FileRequest* request) override; bool ExecuteRequests() override; s32 GetAvailableRequestSlots() const override; void UpdateCompletionEstimates(AZStd::chrono::system_clock::time_point now, AZStd::vector& internalPending, AZStd::deque>& externalPending) override; bool GetFileSize(u64& result, const RequestPath& filePath) override; void FlushCache(const RequestPath& filePath) override; void FlushEntireCache() override; void CollectStatistics(AZStd::vector& statistics) override; protected: static constexpr size_t s_fileNotFound = static_cast(-1); static constexpr s32 s_maxRequests = 1; void ReadFile(FileRequest* request); bool CancelRequest(FileRequest* request); size_t FindFileInCache(const RequestPath& filePath) const; RemoteFileIO m_fileIO; TimedAverageWindow m_fileOpenCloseTimeAverage; TimedAverageWindow m_readTimeAverage; AverageWindow m_readSizeAverage; AZStd::deque m_pendingRequests; AZStd::vector m_fileLastUsed; AZStd::vector m_filePaths; AZStd::vector m_fileHandles; size_t m_activeCacheSlot = s_fileNotFound; }; } // namespace IO } // namespace AZ