pa_atomic_t read_lock;
pa_mutex *write_lock;
pa_semaphore *semaphore;
+ pa_bool_t swapped;
};
pa_aupdate *pa_aupdate_new(void) {
n = (unsigned) pa_atomic_load(&a->read_lock);
+ a->swapped = FALSE;
+
return !WHICH(n);
}
break;
}
+ a->swapped = TRUE;
+
return WHICH(n);
}
void pa_aupdate_write_end(pa_aupdate *a) {
pa_assert(a);
+ if (!a->swapped)
+ pa_aupdate_write_swap(a);
+
pa_mutex_unlock(a->write_lock);
}
* pa_update_write_end(a)
* }
*
+ * In some cases keeping both structures up-to-date might not be
+ * necessary, since they are fully rebuilt on each iteration
+ * anyway. In that case you may leave the _write_swap() call out, it
+ * will then be done implicitly in the _write_end() invocation.
*/
#endif