Provide more extensive listener features.

This enables listeners to be notified of not only value updates, but also flag
changes and deletions by using a bitmask to specify what notifications are
desired.  The old API (which only provided a new/not new) flag is still
supported.  This also subsumes the feature to listen to local changes (that's
one of the bitmask options).
This commit is contained in:
Peter Johnson
2015-09-25 11:54:17 -07:00
parent 51064f5e75
commit 90959defd9
17 changed files with 246 additions and 128 deletions

View File

@@ -169,15 +169,14 @@ void NT_Flush(void) { nt::Flush(); }
unsigned int NT_AddEntryListener(const char *prefix, size_t prefix_len,
void *data,
NT_EntryListenerCallback callback,
int immediate_notify, int local_notify) {
unsigned int flags) {
return nt::AddEntryListener(
StringRef(prefix, prefix_len),
[=](unsigned int uid, StringRef name, std::shared_ptr<Value> value,
bool is_new) {
callback(uid, data, name.data(), name.size(), &value->value(), is_new);
unsigned int flags_) {
callback(uid, data, name.data(), name.size(), &value->value(), flags_);
},
immediate_notify != 0,
local_notify != 0);
flags);
}
void NT_RemoveEntryListener(unsigned int entry_listener_uid) {