1
0
mirror of https://gitlab.gnome.org/GNOME/nautilus synced 2024-06-30 23:46:35 +00:00

file-changes-queue: Make sure only one file queue is created

Since NautilusFileChangesQueue is called from multiple threads,
a simple NULL check can't prevent init from happening twice.
Use GOnce to make sure we only init once and gain some (tiny)
performance benefit over the NULL check.
This commit is contained in:
Corey Berla 2024-01-07 18:59:48 -08:00 committed by Peter Eisenmann
parent 279d4de256
commit bf0d53b948

View File

@ -44,10 +44,12 @@ static GAsyncQueue *
nautilus_file_changes_queue_get (void)
{
static GAsyncQueue *file_changes_queue;
static gsize init_value = 0;
if (file_changes_queue == NULL)
if (g_once_init_enter (&init_value))
{
file_changes_queue = g_async_queue_new ();
g_once_init_leave (&init_value, 1);
}
return file_changes_queue;