mirror of
https://github.com/ETLCPP/etl.git
synced 2026-11-09 22:59:47 +08:00
Added lock/unlock interface
This commit is contained in:
parent
2e7c79ed38
commit
66304646a5
@ -46,6 +46,24 @@ namespace etl
|
||||
|
||||
virtual ~ireference_counted_message_pool() {}
|
||||
virtual void release(const etl::ireference_counted_message& msg) = 0;
|
||||
|
||||
//***************************************************************************
|
||||
/// The pool lock function.
|
||||
/// Override to add thread or interrupt locking to the pool.
|
||||
//***************************************************************************
|
||||
virtual void lock()
|
||||
{
|
||||
// The default implementation does nothing.
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// The pool unlock function.
|
||||
/// Override to add thread or interrupt unlocking to the pool.
|
||||
//***************************************************************************
|
||||
virtual void unlock()
|
||||
{
|
||||
// The default implementation does nothing.
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -116,7 +116,9 @@ namespace etl
|
||||
|
||||
prcm_t p = ETL_NULLPTR;
|
||||
|
||||
lock();
|
||||
p = static_cast<prcm_t>(memory_block_allocator.allocate(sizeof(rcm_t)));
|
||||
unlock();
|
||||
|
||||
if (p != ETL_NULLPTR)
|
||||
{
|
||||
@ -134,7 +136,9 @@ namespace etl
|
||||
void release(const etl::ireference_counted_message& rcmessage)
|
||||
{
|
||||
rcmessage.~ireference_counted_message();
|
||||
lock();
|
||||
bool released = memory_block_allocator.release(&rcmessage);
|
||||
unlock();
|
||||
|
||||
ETL_ASSERT(released, ETL_ERROR(etl::reference_counted_message_pool_release_failure));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user