3 * Linearizable property bag.
6 * Rodrigo Kumpera (kumpera@gmail.com)
8 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
10 #include <mono/metadata/property-bag.h>
11 #include <mono/utils/atomic.h>
12 #include <mono/utils/mono-membar.h>
15 * mono_property_bag_get:
17 * Return the value of the property with TAG or NULL.
18 * This doesn't take any locks.
21 mono_property_bag_get (MonoPropertyBag *bag, int tag)
23 MonoPropertyBagItem *item;
25 for (item = bag->head; item && item->tag <= tag; item = item->next) {
33 * mono_property_bag_add:
35 * Store VALUE in the property bag. Return the previous value
36 * with the same tag, or NULL. VALUE should point to a structure
37 * extending the MonoPropertyBagItem structure with the 'tag'
39 * This doesn't take any locks.
42 mono_property_bag_add (MonoPropertyBag *bag, void *value)
44 MonoPropertyBagItem *cur, **prev, *item = value;
46 mono_memory_barrier (); //publish the values in value
52 if (!cur || cur->tag > tag) {
54 if (InterlockedCompareExchangePointer ((void*)prev, item, cur) == cur)
57 } else if (cur->tag == tag) {