Skip to content

Instantly share code, notes, and snippets.

@cbodley
Last active July 12, 2019 20:37
Show Gist options
  • Save cbodley/12fce5b6a7bf9b3cfb477df77d6f464c to your computer and use it in GitHub Desktop.
Save cbodley/12fce5b6a7bf9b3cfb477df77d6f464c to your computer and use it in GitHub Desktop.
cls/queue/queue.h library
struct cls_queue_marker { uint64_t gen; uint64_t offset; };
struct cls_queue_header;
struct cls_queue_entry { cls_queue_marker marker; bufferlist data; };
int queue_marker_encode(const cls_queue_marker& marker, std::string& encoded);
int queue_marker_decode(const std::string& encoded, cls_queue_marker& marker);
int queue_header_read(cls_method_context_t hctx, cls_queue_header&);
int queue_header_write(cls_method_context_t hctx, const cls_queue_header&);
// list up to max entries from the given marker. if more entries follow, a
// next_marker is assigned to continue listing
int queue_list(cls_method_context_t hctx, const cls_queue_header& queue,
const cls_queue_marker& marker, int max,
std::vector<cls_queue_entry>* entries,
std::optional<cls_queue_marker>* next_marker);
// insert a single entry at the tail of the queue
int queue_enqueue(cls_method_context_t hctx, cls_queue_header& queue,
bufferlist&& entry);
// insert the given entries at the tail of the queue
int queue_enqueue(cls_method_context_t hctx, cls_queue_header& queue,
std::vector<bufferlist>&& entries); // or (Iter first, Iter last)
// remove all entries from the front of the queue up to the given marker
int queue_trim(cls_method_context_t hctx, cls_queue_header& queue,
const cls_queue_marker& marker);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment