On Tue, 8 Apr 2008 14:02:50 -0300 "Gustavo Sverzut Barbieri"
<[EMAIL PROTECTED]> babbled:
> On Tue, Apr 8, 2008 at 11:05 AM, Cedric BAIL <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > This patch doesn't break anything at this time :-) It's a
> > standalone feature that just add the possibility to evas to receive
> > events from another thread. It introduce 3 new API.
>
> I'm not sure the fd must be set to non-block, this might cause more
> trouble than good. I'd make it blocker for now and handle things
> properly using select(), or believe that when the file descriptor is
> ready to read (from ecore_fd_main...) we can read everything (ie: no
> partial writes, no threads will die with incomplete writes).
non-block is fine. that's what select() is for :) read the fd while there are
things to read - then stop and let select tell u more is there to read. this fd
is to let evas wake up the calling program for an event that happened
asynchronously - so that's all we need. it really only needs to write 1 word or
byte down the pipe as a signal. personally i'd write a void * (pointer) that is
a pointer to a message (struct) of some sort. a standard one. it is the
reader's job to take the struct, pass it on to some handler and free it when
done. posting events is just a matter of waking the process up. you want to do
this for example when an image has finished decoding (maybe if u want
progressive load u do it multiple times during load). this is very useful. :)
> > * Retrieve the fd that need to be monitored by ecore :
> > EAPI int evas_async_events_fd_get();
>
> missing (void)
yeah. :)
> > * Process all pending event in the pipe (This function could be called
> > without any event in the pipe) :
> > EAPI int evas_async_events_process();
>
> missing (void), also true for init, shutdown...
>
> also, "do ... while (check == sizeof(current))" logic is wrong, you
> should "check += read(..., todo)" and also change where to load the
> rest of it.
>
> Actually I would rewrite it as:
>
> int todo = sizeof(current);
> char *p = (char *)¤t;
> do
> {
> int n;
> n = read(_fd_read, p, todo);
> if (n == -1)
> {
> if (errno == EAGAIN || errno == EINTR)
> continue;
> else
> HANDLE_ERROR();
> }
> todo -= n;
> p += n;
> } while (todo > 0)
>
>
>
> > * Push an event inside the pipe from another thread :
> > EAPI Evas_Bool evas_async_events_put(Evas_Object *obj,
> > Evas_Callback_Type type, void *event_info);
>
> Write logic is also wrong.
>
> &new + offset
>
> given that new is of type Evas_Event_Async is not what you want. This
> pointer arithmetic is like vector indexing, so it would be like:
>
> new[offset]
>
> You need to cast it to some type that is the size of a byte, like char:
>
> ((char *)&new) + offset
>
> is fine. But I would rewrite it like I did for read.
>
>
> > I currently don't have any code using it, but I plan to use this for
> > the coming background loading of image. So please review it.
>
> done :-)
>
>
> I'm not sure about evas_init() doing this. Nothing against it, but
> maybe some purist wouldn't like to have pthread mutexes created.
i would make this optional. if u are never going to use async stuff - it should
just do nothing. the fd should just never wake up, or what is done in a thread
can be just done in-line and the wakeup can be emulated.
> --
> Gustavo Sverzut Barbieri
> http://profusion.mobi
> Embedded Systems
> --------------------------------------
> MSN: [EMAIL PROTECTED]
> Skype: gsbarbieri
> Mobile: +55 (81) 9927 0010
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Register now and save $200. Hurry, offer ends at 11:59 p.m.,
> Monday, April 7! Use priority code J8TLD2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> _______________________________________________
> enlightenment-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
>
--
------------- Codito, ergo sum - "I code, therefore I am" --------------
The Rasterman (Carsten Haitzler) [EMAIL PROTECTED]
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
enlightenment-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel