X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Finvbloom%2Finvbloom.h;h=a1c83c77641d6416032383abf4af4609f2922b8a;hb=8ad6ab9ce9b78c6b28b727b11d571d11856479c6;hp=d30223d2fe3e4d6f53e92c26217e3c47123bc114;hpb=d92975243f4975a08d6581a2f9cf8091a0695e04;p=ccan diff --git a/ccan/invbloom/invbloom.h b/ccan/invbloom/invbloom.h index d30223d2..a1c83c77 100644 --- a/ccan/invbloom/invbloom.h +++ b/ccan/invbloom/invbloom.h @@ -11,7 +11,7 @@ struct invbloom { u32 salt; s32 *count; /* [n_elems] */ u8 *idsum; /* [n_elems][id_size] */ - void (*singleton)(struct invbloom *ib, size_t elem, void *); + void (*singleton)(struct invbloom *ib, size_t elem, bool, void *); void *singleton_data; }; @@ -31,7 +31,7 @@ struct invbloom *invbloom_new_(const tal_t *ctx, size_t n_elems, u32 salt); /** - * invbloom_singleton_cb - set callback for when a singleton is found. + * invbloom_singleton_cb - set callback for a singleton created/destroyed. * @ib: the invertable bloom lookup table. * @cb: the function to call (or NULL for none) * @data: the data to hand to the function. @@ -40,15 +40,21 @@ struct invbloom *invbloom_new_(const tal_t *ctx, * possibly multiple times for a single call. The particular * @ib bucket will be consistent, but the rest of the table may * not be. + * + * @cb is of form "void @cb(struct invbloom *ib, size_t bucket, bool + * before, data)". @before is true if the call is done before the + * singleton in @bucket is removed (ie. ib->counts[bucket] is -1 or 1, + * but is about to change). @before is false if the call is done + * after the operation, and the bucket is now a singleton. */ #define invbloom_singleton_cb(ib, cb, data) \ invbloom_singleton_cb_((ib), \ typesafe_cb_preargs(void, void *, (cb), (data), \ - struct invbloom *, size_t), (data)) + struct invbloom *, size_t, bool), (data)) void invbloom_singleton_cb_(struct invbloom *ib, void (*cb)(struct invbloom *, - size_t bucket, void *), + size_t bucket, bool before, void *), void *data); /**