parallel/stack: add clone method
This commit is contained in:
parent
e723684347
commit
766e7d0370
@ -44,6 +44,17 @@ namespace cruft::parallel {
|
||||
return *this;
|
||||
}
|
||||
|
||||
stack clone (void) const
|
||||
{
|
||||
stack res (capacity ());
|
||||
|
||||
std::lock_guard lk (m_lock);
|
||||
res.m_cursor = m_cursor.load ();
|
||||
res.m_store = m_store;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/// Thread safe swapping with the supplied object
|
||||
void swap (stack &rhs)
|
||||
@ -146,7 +157,7 @@ namespace cruft::parallel {
|
||||
using index_type = std::size_t;
|
||||
using raw_type = std::aligned_storage_t<sizeof(ValueT), alignof(ValueT)>;
|
||||
|
||||
cruft::thread::spinlock m_lock;
|
||||
mutable cruft::thread::spinlock m_lock;
|
||||
std::atomic<index_type> m_cursor;
|
||||
std::vector<raw_type> m_store;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user