AMPS C# Client  5.3.5.0
AMPS C# Client for .NET
AMPS.Client.BookmarkRingBuffer Class Reference

A ring buffer of bookmarks and activation status. Used by all of the bookmark stores to track state of bookmarks we need to hold on to, either because they're active or because they're after an active one. More...

Classes

class  Entry
 Represents a single entry in an array of bookmarks More...
 

Public Member Functions

 BookmarkRingBuffer ()
 Initializes the underlying array, and sets the "last discarded" value to something reasonable. More...
 
void reset ()
 Resets this bookmark ring buffer for reuse by clearing out its state. More...
 
int capacity ()
 Size of underlying array More...
 
Entry getByIndex (long index)
 Retrieves the entry from the bookmark ring buffer based on the specified index. More...
 
BookmarkField getLastDiscarded ()
 Returns the "last discarded" bookmark. This may be a newer bookmark than the one you last passed to discard(), if you're discarding out of order. More...
 
bool isEmpty ()
 Returns if the buffer is currently empty. More...
 
long getStartIndex ()
 Returns the index value associated with the first valid Entry in self. More...
 
long getEndIndex ()
 Gets the end index (i.e., the index value one greater than the last valid Entry) of the bookmark ring buffer. More...
 
long log (BookmarkField bookmark)
 Logs the bookmark by allocating an Entry, setting the Entry to active, copying the bookmark value to that entry, and returning the index of that entry. More...
 
long relog (long oldIndex, BookmarkField bookmark)
 
bool discard (long index)
 Discards an entry by index from the bookmark ring buffer. If the discard is completed, lastDiscarded will change, otherwise the discard is cached in the entry, and the getLastDiscarded() value is unchanged. More...
 
Entry find (BookmarkField field)
 Finds an entry in the bookmark ring buffer with a specified bookmark field. More...
 
void checkResize ()
 Called to check if resizing of the BookmarkRingBuffer is possible. More...
 
void setResizeHandler (BookmarkStoreResizeHandler handler, BookmarkStore store)
 Call this when you want to set a resize handler that is invoked when a store needs a resize. More...
 
void setSubId (Field sub)
 Sets the Subscription Identifier for the bookmark. More...
 
long setRecovery ()
 Sets the recovery state of the BookmarkRingBuffer. More...
 
IList< EntrygetRecoveryEntries ()
 Gets a list of recovery entries from the BookmarkRingBuffer. More...
 
void getActiveEntries (IList< Entry > entryList_)
 Gets a list of active entries in the BookmarkRingBuffer. More...
 

Static Public Attributes

const int UNSET_INDEX = -1
 Constant representing an unset index value. More...
 

Detailed Description

A ring buffer of bookmarks and activation status. Used by all of the bookmark stores to track state of bookmarks we need to hold on to, either because they're active or because they're after an active one.

Constructor & Destructor Documentation

◆ BookmarkRingBuffer()

AMPS.Client.BookmarkRingBuffer.BookmarkRingBuffer ( )
inline

Initializes the underlying array, and sets the "last discarded" value to something reasonable.

Member Function Documentation

◆ capacity()

int AMPS.Client.BookmarkRingBuffer.capacity ( )
inline

Size of underlying array

Returns
Current capacity of self.

◆ checkResize()

void AMPS.Client.BookmarkRingBuffer.checkResize ( )
inline

Called to check if resizing of the BookmarkRingBuffer is possible.

◆ discard()

bool AMPS.Client.BookmarkRingBuffer.discard ( long  index)
inline

Discards an entry by index from the bookmark ring buffer. If the discard is completed, lastDiscarded will change, otherwise the discard is cached in the entry, and the getLastDiscarded() value is unchanged.

Parameters
indexThe index of the entry.
Returns
True if this caused lastDiscarded to change.

◆ find()

Entry AMPS.Client.BookmarkRingBuffer.find ( BookmarkField  field)
inline

Finds an entry in the bookmark ring buffer with a specified bookmark field.

Parameters
fieldThe bookmark field to search for.
Returns
The entry with the specified bookmark field if found; otherwise, null

◆ getActiveEntries()

void AMPS.Client.BookmarkRingBuffer.getActiveEntries ( IList< Entry entryList_)
inline

Gets a list of active entries in the BookmarkRingBuffer.

Parameters
entryList_The list to which active entries are added.

◆ getByIndex()

Entry AMPS.Client.BookmarkRingBuffer.getByIndex ( long  index)
inline

Retrieves the entry from the bookmark ring buffer based on the specified index.

Parameters
indexAn index returned by .getIndex(), getStartIndex(), getEndIndex(), log, etc.
Returns
The Entry at the specified index, or null if the index is out of range.

◆ getEndIndex()

long AMPS.Client.BookmarkRingBuffer.getEndIndex ( )
inline

Gets the end index (i.e., the index value one greater than the last valid Entry) of the bookmark ring buffer.

Returns
index 1 greater than last valid entry.

◆ getLastDiscarded()

BookmarkField AMPS.Client.BookmarkRingBuffer.getLastDiscarded ( )
inline

Returns the "last discarded" bookmark. This may be a newer bookmark than the one you last passed to discard(), if you're discarding out of order.

Returns
The last bookmark to be discarded.

◆ getRecoveryEntries()

IList<Entry> AMPS.Client.BookmarkRingBuffer.getRecoveryEntries ( )
inline

Gets a list of recovery entries from the BookmarkRingBuffer.

Returns
A list of recovery entries.

◆ getStartIndex()

long AMPS.Client.BookmarkRingBuffer.getStartIndex ( )
inline

Returns the index value associated with the first valid Entry in self.

Returns
The start index if the ring buffer is not empty; otherwise, UNSET_INDEX.</return>

◆ isEmpty()

bool AMPS.Client.BookmarkRingBuffer.isEmpty ( )
inline

Returns if the buffer is currently empty.

Returns
True if self is empty and false otherwise.

◆ log()

long AMPS.Client.BookmarkRingBuffer.log ( BookmarkField  bookmark)
inline

Logs the bookmark by allocating an Entry, setting the Entry to active, copying the bookmark value to that entry, and returning the index of that entry.

Parameters
bookmarkThe bookmark to log.
Returns
The index of the new Entry.

◆ relog()

long AMPS.Client.BookmarkRingBuffer.relog ( long  oldIndex,
BookmarkField  bookmark 
)
inline

WARNING: Deprecated. Do Not Use. The notion of a separate "recovered bookmark" section within the ring buffer and the ability to re-log/re-order those entries into the main/active ring buffer section is an obsolete concept that hasn't been needed since the AMPS server stopped providing persisted acks for every message delivered on a replay (i.e. not needed since AMPS 4.0). The bookmark ring buffer has been simplified to remove this concept since a bug was discovered in it (AC-953).

Old Docs:

Re-logs the bookmark by copying an Entry to a new location and returning the index of that new location.

Parameters
bookmarkthe index to move
Returns
the index of the new Entry.

◆ reset()

void AMPS.Client.BookmarkRingBuffer.reset ( )
inline

Resets this bookmark ring buffer for reuse by clearing out its state.

◆ setRecovery()

long AMPS.Client.BookmarkRingBuffer.setRecovery ( )
inline

Sets the recovery state of the BookmarkRingBuffer.

Returns
The recovery index.

◆ setResizeHandler()

void AMPS.Client.BookmarkRingBuffer.setResizeHandler ( BookmarkStoreResizeHandler  handler,
BookmarkStore  store 
)
inline

Call this when you want to set a resize handler that is invoked when a store needs a resize.

Parameters
handlerThe handler to invoke for the resize.
storeThe associated BookmarkStore to be resized.

◆ setSubId()

void AMPS.Client.BookmarkRingBuffer.setSubId ( Field  sub)
inline

Sets the Subscription Identifier for the bookmark.

Parameters
subThe Field object to copy as the new SubId.

Member Data Documentation

◆ UNSET_INDEX

const int AMPS.Client.BookmarkRingBuffer.UNSET_INDEX = -1
static

Constant representing an unset index value.


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