checkpoint

This commit is contained in:
Antonio SJ Musumeci 2023-04-25 20:37:38 -04:00
parent 5fc35874ac
commit c96bac9cb8
3 changed files with 15 additions and 13 deletions

View File

@ -24,14 +24,14 @@ public:
push(const T& item_) push(const T& item_)
{ {
{ {
std::unique_lock guard(_queue_lock); std::unique_lock<std::mutex> guard(_queue_lock);
_condition_push.wait(guard, [&]() { return _queue.size() < _max_size || !_block; }); _condition_push.wait(guard, [&]() { return _queue.size() < _max_size || !_block; });
if(_queue.size() == _max_size) if(_queue.size() == _max_size)
return false; return false;
_queue.push(item); _queue.push(item_);
} }
_condition_pop.notify_one(); _condition_pop.notify_one();
@ -43,7 +43,7 @@ public:
push(T&& item_) push(T&& item_)
{ {
{ {
std::unique_lock guard(_queue_lock); std::unique_lock<std::mutex> guard(_queue_lock);
_condition_push.wait(guard, [&]() { return _queue.size() < _max_size || !_block; }); _condition_push.wait(guard, [&]() { return _queue.size() < _max_size || !_block; });
@ -61,7 +61,7 @@ public:
emplace(Args&&... args_) emplace(Args&&... args_)
{ {
{ {
std::unique_lock guard(_queue_lock); std::unique_lock<std::mutex> guard(_queue_lock);
_condition_push.wait(guard, [&]() { return _queue.size() < _max_size || !_block; }); _condition_push.wait(guard, [&]() { return _queue.size() < _max_size || !_block; });
@ -80,7 +80,7 @@ public:
pop(T& item_) pop(T& item_)
{ {
{ {
std::unique_lock guard(_queue_lock); std::unique_lock<std::mutex> guard(_queue_lock);
_condition_pop.wait(guard, [&]() { return !_queue.empty() || !_block; }); _condition_pop.wait(guard, [&]() { return !_queue.empty() || !_block; });
if(_queue.empty()) if(_queue.empty())
@ -99,7 +99,7 @@ public:
std::size_t std::size_t
size() const size() const
{ {
std::lock_guard guard(_queue_lock); std::lock_guard<std::mutex> guard(_queue_lock);
return _queue.size(); return _queue.size();
} }
@ -113,7 +113,7 @@ public:
bool bool
empty() const empty() const
{ {
std::lock_guard guard(_queue_lock); std::lock_guard<std::mutex> guard(_queue_lock);
return _queue.empty(); return _queue.empty();
} }
@ -121,7 +121,7 @@ public:
bool bool
full() const full() const
{ {
std::lock_guard lock(_queue_lock); std::lock_guard<std::mutex> lock(_queue_lock);
return (_queue.size() == capacity()); return (_queue.size() == capacity());
} }
@ -129,7 +129,7 @@ public:
void void
block() block()
{ {
std::lock_guard guard(_queue_lock); std::lock_guard<std::mutex> guard(_queue_lock);
_block = true; _block = true;
} }
@ -137,7 +137,7 @@ public:
unblock() unblock()
{ {
{ {
std::lock_guard guard(_queue_lock); std::lock_guard<std::mutex> guard(_queue_lock);
_block = false; _block = false;
} }
@ -148,7 +148,7 @@ public:
bool bool
blocking() const blocking() const
{ {
std::lock_guard guard(_queue_lock); std::lock_guard<std::mutex> guard(_queue_lock);
return _block; return _block;
} }

View File

@ -30,6 +30,7 @@
static std::uint32_t g_PAGESIZE = 0; static std::uint32_t g_PAGESIZE = 0;
static std::uint32_t g_BUFSIZE = 0; static std::uint32_t g_BUFSIZE = 0;
static std::uint32_t g_MAX_ALLOCS = 128;
static std::mutex g_MUTEX; static std::mutex g_MUTEX;
static std::vector<fuse_msgbuf_t*> g_MSGBUF_STACK; static std::vector<fuse_msgbuf_t*> g_MSGBUF_STACK;

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "unbounded_queue.hpp" #include "unbounded_queue.hpp"
#include "bounded_queue.hpp"
#include <tuple> #include <tuple>
#include <atomic> #include <atomic>