nostrdb: ndb: add ndb_poll_for_notes
The polling variant of ndb_wait_for_notes. This makes more sense for realtime apps like notedeck Changelog-Added: Add ndb_poll_for_notes Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
committed by
Daniel D’Aquino
parent
c8d88058d4
commit
62625c6ff3
@@ -5614,6 +5614,20 @@ struct ndb_subscription *ndb_find_subscription(struct ndb *ndb, uint64_t subid)
|
||||
return sub;
|
||||
}
|
||||
|
||||
int ndb_poll_for_notes(struct ndb *ndb, uint64_t subid, uint64_t *note_ids,
|
||||
int note_id_capacity)
|
||||
{
|
||||
struct ndb_subscription *sub;
|
||||
|
||||
if (subid == 0)
|
||||
return 0;
|
||||
|
||||
if (!(sub = ndb_find_subscription(ndb, subid)))
|
||||
return 0;
|
||||
|
||||
return prot_queue_try_pop_all(&sub->inbox, note_ids, note_id_capacity);
|
||||
}
|
||||
|
||||
int ndb_wait_for_notes(struct ndb *ndb, uint64_t subid, uint64_t *note_ids,
|
||||
int note_id_capacity)
|
||||
{
|
||||
|
||||
@@ -486,8 +486,8 @@ void ndb_filter_destroy(struct ndb_filter *);
|
||||
|
||||
// SUBSCRIPTIONS
|
||||
uint64_t ndb_subscribe(struct ndb *, struct ndb_filter *, int num_filters);
|
||||
int ndb_wait_for_notes(struct ndb *, uint64_t subid, uint64_t *note_ids,
|
||||
int note_id_capacity);
|
||||
int ndb_wait_for_notes(struct ndb *, uint64_t subid, uint64_t *note_ids, int note_id_capacity);
|
||||
int ndb_poll_for_notes(struct ndb *, uint64_t subid, uint64_t *note_ids, int note_id_capacity);
|
||||
int ndb_unsubscribe(int subid);
|
||||
|
||||
// FULLTEXT SEARCH
|
||||
|
||||
Reference in New Issue
Block a user