| 81 | } |
| 82 | |
| 83 | void NetworkPeer::CreateMessageBuffers() |
| 84 | { |
| 85 | PROFILE_MEM(Networking); |
| 86 | ASSERT(MessageBuffer == nullptr); |
| 87 | |
| 88 | const uint32 pageSize = Platform::GetCPUInfo().PageSize; |
| 89 | |
| 90 | // Calculate total size in bytes |
| 91 | const uint64 totalSize = static_cast<uint64>(Config.MessagePoolSize) * Config.MessageSize; |
| 92 | |
| 93 | // Calculate the amount of pages that we need |
| 94 | const uint32 numPages = totalSize > pageSize ? Math::CeilToInt(totalSize / static_cast<float>(pageSize)) : 1; |
| 95 | |
| 96 | MessageBuffer = static_cast<uint8*>(Platform::AllocatePages(numPages, pageSize)); |
| 97 | Platform::MemorySet(MessageBuffer, 0, numPages * pageSize); |
| 98 | } |
| 99 | |
| 100 | void NetworkPeer::DisposeMessageBuffers() |
| 101 | { |