f9af76c364
Summary: data_structures moved from src/ Test Plan: manual Reviewers: sale Subscribers: buda, sale Differential Revision: https://memgraph.phacility.com/D14
33 lines
451 B
C++
33 lines
451 B
C++
#pragma once
|
|
|
|
#include <stack>
|
|
|
|
#include "threading/sync/spinlock.hpp"
|
|
#include "threading/sync/lockable.hpp"
|
|
|
|
template <class T>
|
|
class SpinLockStack : Lockable<SpinLock>
|
|
{
|
|
public:
|
|
|
|
T pop()
|
|
{
|
|
auto guard = acquire();
|
|
|
|
T elem = stack.top();
|
|
stack.pop();
|
|
|
|
return elem;
|
|
}
|
|
|
|
void push(const T& elem)
|
|
{
|
|
auto guard = acquire();
|
|
|
|
stack.push(elem);
|
|
}
|
|
|
|
private:
|
|
std::stack<T> stack;
|
|
};
|