replace_data
Description:
[ Version ( since = "2.34" ) ]
public bool replace_data<G,T> (string key, G oldval, owned T newval, out DestroyNotify? old_destroy)
Compares the user data for the key key
on this with oldval
, and if they are the
same, replaces oldval
with newval
.
This is like a typical atomic compare-and-exchange operation, for user data on an object.
If the previous value was replaced then ownership of the old value (oldval
) is passed to the caller, including the registered
destroy notify for it (passed out in old_destroy
). It’s up to the caller to free this as needed, which may or may not include
using old_destroy
as sometimes replacement should not destroy the object in the normal way.
See g_object_set_data
for guidance on using a small, bounded set of values for key
.
Parameters:
this |
the Object to store user data on |
key |
a string, naming the user data pointer |
oldval |
the old value to compare against |
newval |
the new value |
old_destroy |
destroy notify for the existing value |
destroy |
a destroy notify for the new value |
Returns:
true if the existing value for |