CyberEngineMkIII
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
CYBVirtualMemory.hpp
Go to the documentation of this file.
1 #pragma once
3 
4 namespace CYB {
5  namespace Platform {
6  namespace System {
9  public:
11  enum class AccessLevel {
12  READ,
13  READ_WRITE,
14  NONE,
15  };
16  private:
17  void* const FReservation;
18  unsigned long long FCommitSize;
19  const unsigned long long FReservationSize;
20  private:
29  static void* InitReservation(const unsigned long long ANumBytes);
30  public:
38  VirtualMemory(const unsigned long long ANumBytes);
41 
49  void Commit(const unsigned long long ANumBytes);
57  void Discard(void* const AMemory, const unsigned long long ANumBytes) noexcept;
65  void Access(const AccessLevel AAccess);
72  void* operator()(void) const noexcept;
79  unsigned long long CommitSize(void) const noexcept;
86  unsigned long long ReservationSize(void) const noexcept;
87  };
88  };
89  };
90 };
unsigned long long ReservationSize(void) const noexcept
Get the reservation size. Attempting to commit a size larger than this will generate a throw...
const unsigned long long FReservationSize
The size of the reservation.
void * operator()(void) const noexcept
Get the underlying reservation.
void Commit(const unsigned long long ANumBytes)
Commit some amount of memory from a reserved address space. On return, the memory will be usable...
void Discard(void *const AMemory, const unsigned long long ANumBytes) noexcept
Designate an area of memory as not needed for the time being, improving performance. It may be reaccessed at any time, however, it should be assumed to be filled with random data upon doing so.
~VirtualMemory()
Release a reservation. All memory that was used in entire reserved address space will be lost...
unsigned long long FCommitSize
The current size of commited memory in the reservation.
unsigned long long CommitSize(void) const noexcept
Get the current commit size of the reservation.
static void * InitReservation(const unsigned long long ANumBytes)
Reserve some amount of address space for future allocation.
VirtualMemory(const unsigned long long ANumBytes)
Reserve some amount of address space for future allocation.
void *const FReservation
The pointer to the reservation.
void Access(const AccessLevel AAccess)
Set the memory protection on a reservation. Does nothing without a previous commit.
Access and abstraction to the basic OS memory functions.