X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fhmap.h;h=445e74f0b798266e629a0a7f611d6a0d9a62beb6;hb=7614e5d01c3b971c57d825111e412b1182cc04c8;hp=76a73ac1ad23852e01acc003fb07e24820016264;hpb=fc24d64d27b745593fe9d5a6c73dfc6dd9da5983;p=sliver-openvswitch.git diff --git a/lib/hmap.h b/lib/hmap.h index 76a73ac1a..445e74f0b 100644 --- a/lib/hmap.h +++ b/lib/hmap.h @@ -19,6 +19,7 @@ #include #include +#include "ovs-atomic.h" #include "util.h" #ifdef __cplusplus @@ -189,10 +190,13 @@ hmap_capacity(const struct hmap *hmap) } /* Returns true if 'hmap' currently contains no nodes, - * false otherwise. */ + * false otherwise. + * Note: While hmap in general is not thread-safe without additional locking, + * hmap_is_empty() is. */ static inline bool hmap_is_empty(const struct hmap *hmap) { + atomic_thread_fence(memory_order_acquire); return hmap->n == 0; }