Skip to content

Commit

Permalink
Merge pull request #671 from evoskuil/master
Browse files Browse the repository at this point in the history
Remove retainer, add block allocation metadata.
  • Loading branch information
evoskuil committed Aug 12, 2024
2 parents a22a44a + b26bd85 commit ef1cb60
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 23 deletions.
7 changes: 0 additions & 7 deletions include/bitcoin/node/block_arena.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ class BCN_API block_arena final

block_arena& operator=(block_arena&& other) NOEXCEPT;

/// Get memory block retainer mutex.
inline std::shared_mutex& get_mutex() NOEXCEPT
{
return mutex_;
}

void* require(size_t bytes) NOEXCEPT override;

private:
Expand All @@ -57,7 +51,6 @@ class BCN_API block_arena final
size_t capacity() const NOEXCEPT;

// These are thread safe (set only construct).
std::shared_mutex mutex_{};
uint8_t* memory_map_;
size_t size_;

Expand Down
3 changes: 0 additions & 3 deletions include/bitcoin/node/block_memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ class BCN_API block_memory final
/// Each thread obtains an arena of the same size.
arena* get_arena() NOEXCEPT override;

/// Each thread obtains its arena's retainer.
retainer::ptr get_retainer(size_t allocation=zero) NOEXCEPT override;

protected:
block_arena* get_block_arena() const THROWS;

Expand Down
6 changes: 0 additions & 6 deletions src/block_arena.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ block_arena::block_arena(block_arena&& other) NOEXCEPT
block_arena::~block_arena() NOEXCEPT
{
if (!is_null(memory_map_))
{
std::unique_lock lock(mutex_);
free(memory_map_);
}
}

block_arena& block_arena::operator=(block_arena&& other) NOEXCEPT
Expand All @@ -88,10 +85,7 @@ size_t block_arena::capacity() const NOEXCEPT
void* block_arena::require(size_t bytes) NOEXCEPT
{
if (bytes > capacity())
{
std::unique_lock lock{ mutex_ };
offset_ = zero;
}

return memory_map_ + offset_;
}
Expand Down
6 changes: 0 additions & 6 deletions src/block_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ arena* block_memory::get_arena() NOEXCEPT
return get_block_arena();
}

retainer::ptr block_memory::get_retainer(size_t allocation) NOEXCEPT
{
return std::make_shared<retainer>(get_block_arena()->get_mutex(),
allocation);
}

// protected
block_arena* block_memory::get_block_arena() const THROWS
{
Expand Down
2 changes: 1 addition & 1 deletion src/protocols/protocol_block_in_31800.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ void protocol_block_in_31800::complete(const code& ec,
{
notify(ec, chase::checked, height);
fire(events::block_archived, height);
////const auto bytes = block->get_retainer()->allocation();
////const auto bytes = block->get_allocation();
}
}

Expand Down

0 comments on commit ef1cb60

Please sign in to comment.