notmuch/lib/init.cc
David Bremner 8410be8e08 lib: make glib initialization thread-safe
In principle this could be done without depending on C++11 features,
but these features should be available since gcc 4.8.1, and this
localized usage is easy to replace if it turns out to be problematic
for portability.
2021-05-13 22:21:57 -03:00

21 lines
351 B
C++

#include "notmuch-private.h"
#include <mutex>
static void do_init ()
{
/* Initialize the GLib type system and threads */
#if ! GLIB_CHECK_VERSION (2, 35, 1)
g_type_init ();
#endif
g_mime_init ();
_notmuch_filter_init ();
}
void
_notmuch_init ()
{
static std::once_flag initialized;
std::call_once (initialized, do_init);
}