EAPI int eina_threads_init(void) { #ifdef EFL_HAVE_THREADS int ret; #ifdef EINA_HAVE_DEBUG_THREADS assert(pthread_equal(_eina_main_loop, pthread_self())); #endif ++_eina_main_thread_count; ret = _eina_main_thread_count; if(_eina_main_thread_count > 1) return ret; eina_share_common_threads_init(); eina_log_threads_init(); _eina_threads_activated = EINA_TRUE; return ret; #else return 0; #endif }
/** * @brief Initialize the mutexes of the Eina library. * * @return 1 or greater on success, 0 on error. * * This function sets up all the mutexes in all eina modules. It returns 0 on * failure (that is, when one of the module fails to initialize), * otherwise it returns the number of times it has already been * called. * * When the mutexes are not used anymore, call eina_threads_shutdown() to shut down * the mutexes. */ EAPI int eina_threads_init(void) { #ifdef EFL_HAVE_THREADS int ret; #ifdef EFL_HAVE_WIN32_THREADS if (!_mutex) _mutex = CreateMutex(NULL, FALSE, NULL); if (!_mutex) return 0; #endif LOCK(); ++_eina_main_thread_count; ret = _eina_main_thread_count; if (_eina_main_thread_count > 1) { UNLOCK(); return ret; } eina_share_common_threads_init(); eina_log_threads_init(); _threads_activated = EINA_TRUE; return ret; #else return 0; #endif }