Skip to content

Commit

Permalink
[C++]: change member name to avoid macro issues. For #405.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmontgomery committed Oct 27, 2017
1 parent dc44c82 commit e30cc3a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
20 changes: 9 additions & 11 deletions aeron-client/src/main/cpp/util/MemoryMappedFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ namespace aeron { namespace util {
bool MemoryMappedFile::fill(FileHandle fd, size_t size, uint8_t value)
{
uint8_t buffer[8196];
memset(buffer, value, PAGE_SIZE);
memset(buffer, value, m_page_size);

DWORD written = 0;

while (size >= PAGE_SIZE)
while (size >= m_page_size)
{
if (!WriteFile(fd.handle, buffer, (DWORD)PAGE_SIZE, &written, NULL))
if (!WriteFile(fd.handle, buffer, (DWORD)m_page_size, &written, NULL))
{
return false;
}
Expand Down Expand Up @@ -94,17 +94,17 @@ MemoryMappedFile::ptr_t MemoryMappedFile::mapExisting(const char *filename, size
#else
bool MemoryMappedFile::fill(FileHandle fd, size_t size, uint8_t value)
{
std::unique_ptr<uint8_t[]> buffer(new uint8_t[PAGE_SIZE]);
memset(buffer.get(), value, PAGE_SIZE);
std::unique_ptr<uint8_t[]> buffer(new uint8_t[m_page_size]);
memset(buffer.get(), value, m_page_size);

while (size >= PAGE_SIZE)
while (size >= m_page_size)
{
if (static_cast<size_t>(write(fd.handle, buffer.get(), PAGE_SIZE)) != PAGE_SIZE)
if (static_cast<size_t>(write(fd.handle, buffer.get(), m_page_size)) != m_page_size)
{
return false;
}

size -= PAGE_SIZE;
size -= m_page_size;
}

if (size)
Expand Down Expand Up @@ -174,9 +174,7 @@ size_t MemoryMappedFile::getMemorySize() const
return m_memorySize;
}

#if !defined(PAGE_SIZE)
size_t MemoryMappedFile::PAGE_SIZE = getPageSize();
#endif
size_t MemoryMappedFile::m_page_size = getPageSize();

#ifdef _WIN32
MemoryMappedFile::MemoryMappedFile(FileHandle fd, size_t offset, size_t length)
Expand Down
4 changes: 1 addition & 3 deletions aeron-client/src/main/cpp/util/MemoryMappedFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ class MemoryMappedFile

std::uint8_t* m_memory = 0;
size_t m_memorySize = 0;
#if !defined(PAGE_SIZE)
static size_t PAGE_SIZE;
#endif
static size_t m_page_size;

This comment has been minimized.

Copy link
@mjpt777

mjpt777 Oct 28, 2017

Contributor

Should this be static? What if multiple clients are used in the same process to different drivers?

This comment has been minimized.

Copy link
@tmontgomery

tmontgomery Oct 30, 2017

Author Contributor

The page size in the logbuffers is handled differently. This is simply for filling in anything created by the client. Which currently.... I don't think we have anything. So, it could be even removed, I think.

static bool fill(FileHandle fd, size_t sz, std::uint8_t);

#ifdef _WIN32
Expand Down

0 comments on commit e30cc3a

Please sign in to comment.