Skip to content

Commit

Permalink
cppring: Add Ring::empty function (and header for ssize_t)
Browse files Browse the repository at this point in the history
  • Loading branch information
shramov committed Dec 19, 2024
1 parent 8adec19 commit efc4acb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/tll/cppring.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#ifndef _TLL_CPPRING_H
#define _TLL_CPPRING_H

#include <sys/types.h>

#include <atomic>
#include <cerrno>
#include <cstddef>
Expand Down Expand Up @@ -156,6 +158,11 @@ struct RingT
return 0;
}

bool empty() const
{
return head.load(std::memory_order_relaxed) == tail.load(std::memory_order_relaxed);
}

int read(const void **data, size_t *size) const
{
return _read_at(head.load(std::memory_order_relaxed), data, size);
Expand Down

0 comments on commit efc4acb

Please sign in to comment.