mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-07-05 01:41:28 +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:
parent
279d4de256
commit
bf0d53b948
|
@ -44,10 +44,12 @@ static GAsyncQueue *
|
||||||
nautilus_file_changes_queue_get (void)
|
nautilus_file_changes_queue_get (void)
|
||||||
{
|
{
|
||||||
static GAsyncQueue *file_changes_queue;
|
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 ();
|
file_changes_queue = g_async_queue_new ();
|
||||||
|
g_once_init_leave (&init_value, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return file_changes_queue;
|
return file_changes_queue;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user