On Wed, Jun 18, 2008 at 1:53 PM, Cedric BAIL <[EMAIL PROTECTED]> wrote:
> Hi,
>
>  Here is a patch that add support for background preloading of a data
> image. You can now, if you know what you do, ask evas to load the data
> of an image in memory before it is displayed (look at the sample code
> for expedite).
>
>  The code is quite simple, we have now a work queue where we add all
> the Image_Entry we need to preload. They are processed one after the
> other in another thread. When it's done, it notify evas main thread
> with evas async API and work on the next Image_Entry.
>
>  This means that we now require that engine surface creation and
> loader should be thread safe. It's currently the case for all the
> engine I know something about, so this should not break anything.
> Anyway this code is optionnal and could be completely unactivated in a
> per engine basis or globally.
>
> As always have fun reviewing this patch.

so here it goes:

configure.in: $build_async_preload should depend on async_events, no?


-   EAPI Evas_Bool        evas_async_events_put             (void *target,
Evas_Callback_Type type, void *event_info, void (*func)(void *target,
Evas_Callback_Type type, void *event_info));
+   EAPI Evas_Bool        evas_async_events_put             (const void
*target, Evas_Callback_Type type, void *event_info, void (*func)(void
*target, Evas_Callback_Type type, void *event_info));

you made target const, but not in the callback... this is strange.


As for the rest of the code. I told you at IRC, but you insist to not
listen to me, so the review is: do not use mutex or cond, use a pipe!

pseudo code is:

struct work-info:
    action {PROCESS, DIE, CANCEL, DONE, ERROR},
    image_entry *entry;

send-to-worker(work-info):
    preload-queue = evas_list_append(preload-queue, work-info);
    write(worker-fd-w, &work-info, sizeof(work-info)); // wake up
worker thread, that should be sleeping on select()/poll()/read()...

recv-from-worker(): -> work-info
   read(master-fd-r, &work-info, sizeof(work-info))
   return work-info

add-image-to-preload-queue(entry):
    work-info = new();
    work-info->action = PROCESS;
    work-info->entry = entry;
    send-to-worker(work-info)

cancel-image-preload:
    work-info = get_from_list(preload-queue, entry)
    if (!work-info) return; // nothing to cancel
    work-info->action = CANCEL;

shutdown-image-preloader:  // to use on evas_shutdown()
   work-info = new();
   work-info->action = DIE;
   send-to-worker(work-info);
   read(master-fd-read)


main-thread-fd-handler-for-master-fd-read:
   work-info = recv-from-worker()
   switch (work-info->action) {
   case DONE:
       emit-image-preloaded;
       break;
   case ERROR:
       print error;
       break;
   case CANCELLED:
       break;
   case DIE:
        break;
   }
   preload-queue = evas_list_remove(preload-queue, work-info);
   free(work-info);

worker-thread:
    while (1) {
        work-info = read(work-fd-r); // block and sleep
        switch(work-info->action) {
           case DIE:
               write(master-fd-w, &work-info, sizeof(work-info));
               return;
           case PROCESS:
               error = image-load()
               work-info->action = error ? ERROR : DONE;
            case CANCEL:
               write(master-fd-w, &work-info, sizeof(work-info));
               break;
        }
    }


it's a bit long, but should show we need no locks or conds.

-- 
Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
--------------------------------------
MSN: [EMAIL PROTECTED]
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to