示例#1
0
文件: eio_main.c 项目: tguillem/efl
EAPI int
eio_init(void)
{
    if (++_eio_init_count != 1)
        return _eio_init_count;

    if (!eina_init())
    {
        fprintf(stderr, "Eio can not initialize Eina\n");
        return --_eio_init_count;
    }

    _eio_log_dom_global = eina_log_domain_register("eio", EIO_DEFAULT_LOG_COLOR);
    if (_eio_log_dom_global < 0)
    {
        EINA_LOG_ERR("Eio can not create a general log domain.");
        goto shutdown_eina;
    }

    if (!ecore_init())
    {
        ERR("Can not initialize Ecore\n");
        goto unregister_log_domain;
    }

    memset(&progress_pool, 0, sizeof(progress_pool));
    memset(&direct_info_pool, 0, sizeof(direct_info_pool));
    memset(&char_pool, 0, sizeof(char_pool));
    memset(&associate_pool, 0, sizeof(associate_pool));

    eina_lock_new(&(progress_pool.lock));
    progress_pool.mem_size = sizeof (Eio_Progress);
    eina_lock_new(&(direct_info_pool.lock));
    direct_info_pool.mem_size = sizeof (Eio_File_Direct_Info);
    eina_lock_new(&(char_pool.lock));
    char_pool.mem_size = sizeof (Eio_File_Char);
    eina_lock_new(&(associate_pool.lock));
    associate_pool.mem_size = sizeof (Eio_File_Associate);

    eina_spinlock_new(&(memory_pool_lock));
    eina_lock_new(&(memory_pool_mutex));
    eina_condition_new(&(memory_pool_cond), &(memory_pool_mutex));

    eio_monitor_init();

    eina_log_timing(_eio_log_dom_global,
                    EINA_LOG_STATE_STOP,
                    EINA_LOG_STATE_INIT);

    return _eio_init_count;

unregister_log_domain:
    eina_log_domain_unregister(_eio_log_dom_global);
    _eio_log_dom_global = -1;
shutdown_eina:
    eina_shutdown();
    return --_eio_init_count;
}
示例#2
0
void bks_model_init(void) {
   ecore_file_init();
   efreet_init();
   eina_lock_new(&mdl.lock);
   mdl.db_path = _bks_model_path_get();
#ifdef DEBUG
   fprintf(stderr, "Path: %s\n", mdl.db_path);
#endif
}
示例#3
0
Eina_Bool enesim_barrier_new(Enesim_Barrier *barrier, int needed)
{
   barrier->needed = needed;
   barrier->called = 0;
   if (!eina_lock_new(&(barrier->cond_lock)))
     return EINA_FALSE;
   if (!eina_condition_new(&(barrier->cond), &(barrier->cond_lock)))
     return EINA_FALSE;
   return EINA_TRUE;
}
示例#4
0
static void *
eina_one_big_init(const char *context,
                  EINA_UNUSED const char *option,
                  va_list args)
{
   One_Big *pool;
   int item_size;
   size_t length;

   length = context ? strlen(context) + 1 : 0;

   pool = calloc(1, sizeof (One_Big) + length);
   if (!pool)
      return NULL;

   item_size = va_arg(args, int);

   pool->item_size = eina_mempool_alignof(item_size);
   pool->max = va_arg(args, int);

   pool->offset_to_item_inlist = pool->item_size;
   if (pool->offset_to_item_inlist % (int)sizeof(void *) != 0)
     {
        pool->offset_to_item_inlist =
          (((pool->offset_to_item_inlist / (int)sizeof(void *)) + 1) *
           (int)sizeof(void *));
     }

   if (length)
     {
        pool->name = (const char *)(pool + 1);
        memcpy((char *)pool->name, context, length);
     }

#ifdef EINA_HAVE_DEBUG_THREADS
   pool->self = eina_thread_self();
#endif
   eina_lock_new(&pool->mutex);

#ifndef NVALGRIND
   VALGRIND_CREATE_MEMPOOL(pool, 0, 1);
#endif

   return pool;
}
示例#5
0
EAPI void *
ecore_main_loop_thread_safe_call_sync(Ecore_Data_Cb callback,
                                      void         *data)
{
    Ecore_Safe_Call *order;
    void *ret;

    if (!callback) return NULL;

    if (eina_main_loop_is())
    {
        return callback(data);
    }

    order = malloc(sizeof (Ecore_Safe_Call));
    if (!order) return NULL;

    order->cb.sync = callback;
    order->data = data;
    eina_lock_new(&order->m);
    eina_condition_new(&order->c, &order->m);
    order->sync = EINA_TRUE;
    order->suspend = EINA_FALSE;

    _ecore_main_loop_thread_safe_call(order);

    eina_lock_take(&order->m);
    eina_condition_wait(&order->c);
    eina_lock_release(&order->m);

    ret = order->data;

    order->sync = EINA_FALSE;
    order->cb.async = _thread_safe_cleanup;
    order->data = order;

    _ecore_main_loop_thread_safe_call(order);

    return ret;
}
示例#6
0
EAPI int
ecore_thread_main_loop_begin(void)
{
    Ecore_Safe_Call *order;

    if (eina_main_loop_is())
    {
        return ++_thread_loop;
    }

    order = malloc(sizeof (Ecore_Safe_Call));
    if (!order) return -1;

    eina_lock_take(&_thread_id_lock);
    order->current_id = ++_thread_id_max;
    if (order->current_id < 0)
    {
        _thread_id_max = 0;
        order->current_id = ++_thread_id_max;
    }
    eina_lock_release(&_thread_id_lock);

    eina_lock_new(&order->m);
    eina_condition_new(&order->c, &order->m);
    order->suspend = EINA_TRUE;

    _ecore_main_loop_thread_safe_call(order);

    eina_lock_take(&order->m);
    while (order->current_id != _thread_id)
        eina_condition_wait(&order->c);
    eina_lock_release(&order->m);

    eina_main_loop_define();

    _thread_loop = 1;

    return EINA_TRUE;
}
示例#7
0
int
efreet_cache_init(void)
{
    char buf[PATH_MAX];

    _efreet_cache_log_dom = eina_log_domain_register("efreet_cache", EFREET_DEFAULT_LOG_COLOR);
    if (_efreet_cache_log_dom < 0)
        return 0;

    if (!eina_lock_new(&_lock))
    {
        ERR("Could not create lock");
        goto error;
    }

    snprintf(buf, sizeof(buf), "%s/efreet", efreet_cache_home_get());
    if (!ecore_file_mkpath(buf))
    {
        ERR("Failed to create directory '%s'", buf);
    }

    EFREET_EVENT_ICON_CACHE_UPDATE = ecore_event_type_new();
    EFREET_EVENT_DESKTOP_CACHE_UPDATE = ecore_event_type_new();
    EFREET_EVENT_DESKTOP_CACHE_BUILD = ecore_event_type_new();

    themes = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_theme_free));
    icons = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_free));
    fallbacks = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_icon_fallback_free));
    desktops = eina_hash_string_superfast_new(NULL);

    eldbus_init();
    if (efreet_cache_update)
    {
        conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
        if (conn)
        {
            Eldbus_Object *obj;

            obj = eldbus_object_get(conn, BUS, PATH);
            proxy = eldbus_proxy_get(obj, INTERFACE);
            eldbus_proxy_signal_handler_add(proxy, "IconCacheUpdate", icon_cache_update, NULL);
            eldbus_proxy_signal_handler_add(proxy, "DesktopCacheUpdate", desktop_cache_update, NULL);

            eldbus_proxy_call(proxy, "Register", on_send_register, NULL, -1, "s", efreet_language_get());

            /*
             * TODO: Needed?
             eldbus_name_owner_changed_callback_add(conn, BUS, on_name_owner_changed,
             conn, EINA_TRUE);
             */
        }
        else
        {
            /* TODO: Run cache process directly */
        }
    }

    return 1;
error:
    if (themes) eina_hash_free(themes);
    themes = NULL;
    if (icons) eina_hash_free(icons);
    icons = NULL;
    if (fallbacks) eina_hash_free(fallbacks);
    fallbacks = NULL;
    if (desktops) eina_hash_free(desktops);
    desktops = NULL;

    efreet_cache_edd_shutdown();
    return 0;
}
示例#8
0
/**
 * Set up connections, signal handlers, sockets etc.
 * @return 1 or greater on success, 0 otherwise
 *
 * This function sets up all singal handlers and the basic event loop. If it
 * succeeds, 1 will be returned, otherwise 0 will be returned.
 *
 * @code
 * #include <Ecore.h>
 *
 * int main(int argc, char **argv)
 * {
 *   if (!ecore_init())
 *   {
 *     printf("ERROR: Cannot init Ecore!\n");
 *     return -1;
 *   }
 *   ecore_main_loop_begin();
 *   ecore_shutdown();
 * }
 * @endcode
 */
EAPI int
ecore_init(void)
{
    if (++_ecore_init_count != 1)
        return _ecore_init_count;

#ifdef HAVE_LOCALE_H
    setlocale(LC_CTYPE, "");
#endif
    /*
       if (strcmp(nl_langinfo(CODESET), "UTF-8"))
       {
         WRN("Not a utf8 locale!");
       }
     */
#ifdef HAVE_EVIL
    if (!evil_init())
        return --_ecore_init_count;
#endif
    if (!eina_init())
        goto shutdown_evil;
    _ecore_log_dom = eina_log_domain_register("ecore", ECORE_DEFAULT_LOG_COLOR);
    if (_ecore_log_dom < 0)
    {
        EINA_LOG_ERR("Ecore was unable to create a log domain.");
        goto shutdown_log_dom;
    }
    if (getenv("ECORE_FPS_DEBUG")) _ecore_fps_debug = 1;
    if (_ecore_fps_debug) _ecore_fps_debug_init();
    if (!ecore_mempool_init()) goto shutdown_mempool;
    _ecore_main_loop_init();
    _ecore_signal_init();
    _ecore_thread_init();
    _ecore_exe_init();
    _ecore_glib_init();
    _ecore_job_init();
    _ecore_time_init();

    eina_lock_new(&_thread_safety);
    eina_lock_new(&_thread_mutex);
    eina_condition_new(&_thread_cond, &_thread_mutex);
    eina_lock_new(&_thread_feedback_mutex);
    eina_condition_new(&_thread_feedback_cond, &_thread_feedback_mutex);
    _thread_call = ecore_pipe_add(_thread_callback, NULL);
    eina_lock_new(&_thread_id_lock);

    eina_lock_new(&_ecore_main_loop_lock);

#if HAVE_MALLINFO
    if (getenv("ECORE_MEM_STAT"))
    {
        _ecore_memory_pid = getpid();
        ecore_animator_add(_ecore_memory_statistic, NULL);
    }
#endif

#if defined(GLIB_INTEGRATION_ALWAYS)
    if (_ecore_glib_always_integrate) ecore_main_loop_glib_integrate();
#endif

    return _ecore_init_count;

shutdown_mempool:
    ecore_mempool_shutdown();
shutdown_log_dom:
    eina_shutdown();
shutdown_evil:
#ifdef HAVE_EVIL
    evil_shutdown();
#endif
    return --_ecore_init_count;
}
示例#9
0
static void
_eina_stringshare_small_init(void)
{
    eina_lock_new(&_mutex_small);
    memset(&_eina_small_share, 0, sizeof(_eina_small_share));
}
示例#10
0
文件: eina_tmpstr.c 项目: jigpu/efl
Eina_Bool
eina_tmpstr_init(void)
{
   if (!eina_lock_new(&_mutex)) return EINA_FALSE;
   return EINA_TRUE;
}