proxygen
folly::LockFreeRingBuffer< T, Atom >::Cursor Struct Reference

#include <LockFreeRingBuffer.h>

Public Member Functions

 Cursor (uint64_t initialTicket) noexcept
 
bool moveForward (uint64_t steps=1) noexcept
 
bool moveBackward (uint64_t steps=1) noexcept
 

Protected Attributes

uint64_t ticket
 

Friends

class LockFreeRingBuffer
 

Detailed Description

template<typename T, template< typename > class Atom = std::atomic>
struct folly::LockFreeRingBuffer< T, Atom >::Cursor

Opaque pointer to a past or future write. Can be moved relative to its current location but not in absolute terms.

Definition at line 71 of file LockFreeRingBuffer.h.

Constructor & Destructor Documentation

template<typename T, template< typename > class Atom = std::atomic>
folly::LockFreeRingBuffer< T, Atom >::Cursor::Cursor ( uint64_t  initialTicket)
inlineexplicitnoexcept

Definition at line 72 of file LockFreeRingBuffer.h.

72 : ticket(initialTicket) {}

Member Function Documentation

template<typename T, template< typename > class Atom = std::atomic>
bool folly::LockFreeRingBuffer< T, Atom >::Cursor::moveBackward ( uint64_t  steps = 1)
inlinenoexcept

Returns true if this cursor now points to a previous write, false otherwise.

Definition at line 84 of file LockFreeRingBuffer.h.

References shell_builder::steps, ticket, and uint64_t.

Referenced by folly::TEST().

84  {
85  uint64_t prevTicket = ticket;
86  if (steps > ticket) {
87  ticket = 0;
88  } else {
89  ticket -= steps;
90  }
91  return prevTicket != ticket;
92  }
template<typename T, template< typename > class Atom = std::atomic>
bool folly::LockFreeRingBuffer< T, Atom >::Cursor::moveForward ( uint64_t  steps = 1)
inlinenoexcept

Returns true if this cursor now points to a different write, false otherwise.

Definition at line 76 of file LockFreeRingBuffer.h.

References shell_builder::steps, ticket, and uint64_t.

Referenced by folly::TEST().

76  {
77  uint64_t prevTicket = ticket;
78  ticket += steps;
79  return prevTicket != ticket;
80  }

Friends And Related Function Documentation

template<typename T, template< typename > class Atom = std::atomic>
friend class LockFreeRingBuffer
friend

Definition at line 96 of file LockFreeRingBuffer.h.

Member Data Documentation

template<typename T, template< typename > class Atom = std::atomic>
uint64_t folly::LockFreeRingBuffer< T, Atom >::Cursor::ticket
protected

Definition at line 95 of file LockFreeRingBuffer.h.


The documentation for this struct was generated from the following file: