libostree: Add multiple getter/setter support to OstreeAsyncProgress
OstreeAsyncProgress is thread-safe: it can have keys changed by one thread while another is getting the same keys (modulo some locking contention). However, the thread safety is done at the function call level: if some code calls an OstreeAsyncProgress getter several times, the key fetches are not atomic with respect to each other. In the case of contention on the lock, this can result in consumers of OstreeAsyncProgress data seeing an inconsistent state between the properties they query, which could result in progress reporting inaccuracies. In the uncontested case, this results in the OstreeAsyncProgress lock being locked and unlocked many times more than necessary. Try to improve this by adding new API, which supports getting and setting multiple keys atomically: • ostree_async_progress_get() • ostree_async_progress_set() The new API uses GVariants and varargs: keys are passed as a GVariantType string followed by arguments as for g_variant_new() or g_variant_get(), followed by the next key, etc. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #819 Approved by: cgwalters
This commit is contained in:
1 parent
f74e52a3a0
commit
c27b66de80
4 files changed
+146
No files matched your search
@@ -53,6 +53,10 @@ OstreeAsyncProgress *ostree_async_progress_new_and_connect (void (*changed) (Ost
|
||||
_OSTREE_PUBLIC
|
||||
char *ostree_async_progress_get_status (OstreeAsyncProgress *self);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
void ostree_async_progress_get (OstreeAsyncProgress *self,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
guint ostree_async_progress_get_uint (OstreeAsyncProgress *self,
|
||||
const char *key);
|
||||
@@ -67,6 +71,10 @@ _OSTREE_PUBLIC
|
||||
void ostree_async_progress_set_status (OstreeAsyncProgress *self,
|
||||
const char *status);
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
void ostree_async_progress_set (OstreeAsyncProgress *self,
|
||||
...) G_GNUC_NULL_TERMINATED;
|
||||
|
||||
_OSTREE_PUBLIC
|
||||
void ostree_async_progress_set_uint (OstreeAsyncProgress *self,
|
||||
const char *key,
|
||||
|
||||
Reference in new issue
Block a user