#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2023 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_PLATFORM_TASKS_RESOURCEMANIFEST_H #define NUCLEX_PLATFORM_TASKS_RESOURCEMANIFEST_H #include "Nuclex/Platform/Config.h" #include "Nuclex/Platform/Tasks/ResourceType.h" #include // for std::size_t #include // for std::shared_ptr namespace Nuclex { namespace Platform { namespace Tasks { // ------------------------------------------------------------------------------------------- // /// Listing of resources that are needed to perform a task class NUCLEX_PLATFORM_TYPE ResourceManifest { #pragma region struct Entry /// Specifies the amount of a resource that a task needs to execute public: struct Entry { /// Amount of the resource (core count, bytes memory) the task needs public: std::size_t Amount; /// Kind of resource the task will occupy to do its work public: ResourceType Type; }; #pragma endregion // struct Entry /// Creates a resource manifest with one resource requirement /// Type of resource the manifest should list /// Amount of the resource that is required /// A pointer to the new resource manifest public: NUCLEX_PLATFORM_API static std::shared_ptr Create( ResourceType resourceType, std::size_t resourceAmount ); /// Creates a resource manifest with two resource requirements /// Type of the first resource in the manifest /// Amount required of the first resource /// Type of the second resource in the manifest /// Amount required of the second resource /// A pointer to the new resource manifest public: NUCLEX_PLATFORM_API static std::shared_ptr Create( ResourceType resource1Type, std::size_t resource1Amount, ResourceType resource2Type, std::size_t resource2Amount ); /// Creates a resource manifest with three resource requirements /// Type of the first resource in the manifest /// Amount required of the first resource /// Type of the second resource in the manifest /// Amount required of the second resource /// Type of the third resource in the manifest /// Amount required of the third resource /// A pointer to the new resource manifest public: NUCLEX_PLATFORM_API static std::shared_ptr Create( ResourceType resource1Type, std::size_t resource1Amount, ResourceType resource2Type, std::size_t resource2Amount, ResourceType resource3Type, std::size_t resource3Amount ); /// Builds the sum of two resource manifests /// First resource manifest to combine /// First resource manifest to combine /// A resource manifest that is the sum of both input manifests public: NUCLEX_PLATFORM_API static std::shared_ptr Combine( const std::shared_ptr &first, const std::shared_ptr &second ); /// Number of resources in the manifest public: std::size_t Count; /// List of the resource types with the amount needed of each public: const Entry *Resources; /// Bit mask indicating the hard drives that will be accessed /// /// This field is initialized to 0 (no hard drives accessed). It should be directly /// assigned in case a workload accesses any hard drives. Methods such as /// will use bitwise operations as appropriate for flags. /// public: std::size_t AccessedHardDriveMask; // Could track NetworkAdapters to focus bandwidth on single action, but pointless? // Could track Camera accesses, but makes little sense? }; // ------------------------------------------------------------------------------------------- // /// /// Type of pointer returned by the methods /// typedef std::shared_ptr ResourceManifestPointer; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Platform::Tasks #endif // NUCLEX_PLATFORM_TASKS_RESOURCEMANIFEST_H