From c1cb78d574c0429aa5e3ff3a2b3886e4bc153212 Mon Sep 17 00:00:00 2001 From: bbergeron Date: Wed, 3 Apr 2024 17:32:01 -0400 Subject: Reset Git repo and use a pseudonym to sign commits I used to sign my commits with my real name and my personal email address, which I wanted scrubbed off the "B." pseudosphere. Re-creating a new git repository was safer than simpler than re-writing the history (although the latter could've also worked but, oh well). --- playlist.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 playlist.h (limited to 'playlist.h') diff --git a/playlist.h b/playlist.h new file mode 100644 index 0000000..ed4b19d --- /dev/null +++ b/playlist.h @@ -0,0 +1,33 @@ +#ifndef PLAYLIST_H_ +#define PLAYLIST_H_ + +#include "common.h" + +/** + * Playlist - A thread-safe string queue with support for indexed insert/remove. + */ +typedef struct Playlist Playlist; + +Playlist *playlist_init (void); +void playlist_free (Playlist *pl); +int playlist_enqueue (Playlist *pl, const char *entry); + +/** + * Fetch the next entry in the playlist, blocking the current thread and waiting + * for an entry if needed. The function can be interrupted by sending a signal + * to the waiting thread, in which case *entry remains untouched, -1 is + * returned, and errno is set to EINTR. Returns 0 on success. + */ +int playlist_dequeue(Playlist *pl, struct Entry *entry); + +/** + * Like playlist_dequeue, but returns -1 when the playlist is empty instead of + * locking the thread. Returns 0 on success. + */ +int playlist_try_dequeue(Playlist *pl, struct Entry *entry); + +int playlist_insert (Playlist *pl, unsigned int id, const char *entry); +int playlist_remove (Playlist *pl, unsigned int id, struct Entry *entry); +int playlist_list (Playlist *pl, struct StateInfo *list); + +#endif // PLAYLIST_H_ -- cgit v1.2.3