Skip to content

Commit

Permalink
We we try to write an empty buffer, replace it in the buffer cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
abellgithub committed Oct 19, 2021
1 parent a51906a commit ec62df2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions epf/Cell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ void Cell::write()
size_t size = m_pos - m_buf->data();
if (size)
m_writer->enqueue(m_key, std::move(m_buf), size);
else
m_writer->replace(std::move(m_buf));
}

void Cell::advance()
Expand Down
6 changes: 6 additions & 0 deletions epf/Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ void Writer::enqueue(const VoxelKey& key, DataVecPtr data, size_t dataSize)
m_available.notify_one();
}

void Writer::replace(DataVecPtr data)
{
std::lock_guard<std::mutex> lock(m_mutex);
m_bufferCache.replace(std::move(data));
}

void Writer::stop()
{
{
Expand Down
1 change: 1 addition & 0 deletions epf/Writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Writer
public:
Writer(const std::string& directory, int numThreads, size_t pointSize);

void replace(DataVecPtr data);
void enqueue(const VoxelKey& key, DataVecPtr data, size_t dataSize);
void stop();
const Totals& totals()
Expand Down

0 comments on commit ec62df2

Please sign in to comment.