Skip to content

v2.0.24

Choose a tag to compare

@github-actions github-actions released this 20 May 16:39
refactor(buffer_pool): remove mutex, single-thread by contract

All allocate_buffer() / free_disk_buffer() entry points are reached only
from the libtorrent network thread:
  - allocate_buffer() is called from async_read/write/hash before posting
    work to a worker thread.
  - free_disk_buffer() runs from disk_buffer_holder's destructor, which
    fires either when libtorrent invokes the handler (network thread per
    disk_interface contract) or when our own handler lambda is posted
    back to m_ioc.

libtorrent's session runs a single std::thread on the io_context
(session.cpp:342, only .run() call site in the source), and EZIO uses
the default internal_executor session, so the contract holds.

Drop m_pool_mutex and the lock-passing in allocate_buffer_impl /
check_buffer_level. in_use() may still be read from the stats thread;
the racy read is tolerated for reporting purposes. Document the
contract in buffer_pool.hpp.

Signed-off-by: Date Huang <tjjh89017@hotmail.com>