Add size query to mpmc_queue

This commit is contained in:
rexy712 2021-09-18 15:42:08 -07:00
parent 01e78a1a01
commit 4f379d75ec
2 changed files with 6 additions and 0 deletions

View File

@ -122,6 +122,8 @@ namespace rexy{
void pop(reference t);
bool try_pop(reference t);
size_type size(void)const;
private:
constexpr size_type rotation_cnt(size_type t);
};

View File

@ -209,6 +209,10 @@ namespace rexy{
}
}
template<class T>
auto mpmc_queue<T>::size(void)const -> size_type{
return m_slots.size();
}
template<class T>
constexpr auto mpmc_queue<T>::rotation_cnt(size_type t) -> size_type{
return (t / m_slots.capacity());
}