Camel.ObjectBag

Fields

None

Methods

abort (key)

add (key, object)

destroy ()

get (key)

list ()

peek (key)

rekey (object, new_key)

remove (object)

reserve (key)

Details

class Camel.ObjectBag
abort(key)
Parameters:

key (object or None) – a reserved key

Aborts a key reservation.

add(key, object)
Parameters:

Adds object to self. The key MUST have been previously reserved using Camel.ObjectBag.reserve().

destroy()

Frees self. As a precaution, the function will emit a warning to standard error and return without freeing self if self still has reserved keys.

get(key)
Parameters:

key (object or None) – a key

Returns:

the object corresponding to key, or None if not found

Return type:

object or None

Lookup an object by key. If the key is currently reserved, the function will block until another thread commits or aborts the reservation. The caller owns the reference to the returned object. Use GObject.Object.unref () to unreference it.

list()
Returns:

an array of objects in self

Return type:

[GObject.Object]

Returns a GLib.PtrArray of all the objects in the bag. The caller owns both the array and the object references, so to free the array use:

g_ptr_array_foreach (array, (GFunc) g_object_unref, NULL);
g_ptr_array_free (array, TRUE);
peek(key)
Parameters:

key (object or None) – an unreserved key

Returns:

the object for key, or None if key is reserved or not found

Return type:

object or None

Returns the object for key in self, ignoring any reservations. If it isn’t committed, then it isn’t considered. This should only be used where reliable transactional-based state is not required.

Unlink other “peek” operations, the caller owns the returned object reference. Use GObject.Object.unref () to unreference it.

rekey(object, new_key)
Parameters:

Changes the key for object to new_key, atomically.

It is considered a programming error if object is not found in self. In such case the function will emit a terminal warning and return.

remove(object)
Parameters:

object (object or None) – a GObject.Object

Removes object from self.

reserve(key)
Parameters:

key (object or None) – the key to reserve

Returns:

the object for key, or None if key is not found

Return type:

object or None

Reserves key in self. If key is already reserved in another thread, then wait until the reservation has been committed.

After reserving key, you either get a reference to the object corresponding to key (similar to Camel.ObjectBag.get()) or you get None, signifying that you MUST call either Camel.ObjectBag.add() or Camel.ObjectBag.abort().