diff options
author | bbergeron <[email protected]> | 2024-04-03 17:32:01 -0400 |
---|---|---|
committer | bbergeron <[email protected]> | 2024-04-03 17:32:01 -0400 |
commit | c1cb78d574c0429aa5e3ff3a2b3886e4bc153212 (patch) | |
tree | bf68806bcbddcafafc015b28c25550ea457eeecc /playlist.h |
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).
Diffstat (limited to 'playlist.h')
-rw-r--r-- | playlist.h | 33 |
1 files changed, 33 insertions, 0 deletions
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_ |