Baruch Even <[EMAIL PROTECTED]> writes:

| In my work on the graphics inset I find myself with a need for internal
| events, namely to announce internally that an image has been loaded. The
| problem starts when I want to do the image loading in a second
| thread/fork/whatever, since LyX isn't necessarily (read: isn't) thread
| safe, I can't just use a plain signal/slot mechanism, but rather need to
| do this signal from the main loop.

I think you should drop all concurrency issues at first, for the first
go just let LyX wait for the conversions to finish.
 
| My current plan calls for a toolkit dependant SendEvent() that will send
| the event to the main gui loop, and by some magic this will call the
| correct event handler (possibly by signal/slot) inside the main thread.
| 
| This will allow me to call the insets, notify them that the image is here
| and they can update the image, ask for a redraw if appropriate and so on.
|
| Is this idea acceptable?

It really depends if we do this with exec/fork, or threads.

On what platforms are LyX available today that does not have threads?

With threads we will use a message passing scheme.

## thread
messagequeue.notify("<finished converting>");

## Main tread
For xforms we can use a filedescriptor driven message queue and bind
a callback that knows what to do with fl_add_io_callback.

Unfortunately is xforms not threadsafe so we must be very careful to
not use xforms functions in the thread.

For a fork/exec we could use a pipe and in all practical matters use
te messagequeue that way.


-----------

I am not sure how you are doing this, but I imagine something like:

- insets reqeuest te conversion/rendering of a file.
     - it generates a object a bind a local method to a method in that
       object.
     - the object is sent to the conversion module, the conversion
       module forks/threads
- the normal mainloop continues.
- the mainloop get notiffied and calls a callback routing in the
  conversion module, this callback emits the signal the object that
  the inset passed down in the first place and action is taken.
  The object is deleted and all is nice...

This is either too complex or too simplistic...

        Lgb

Reply via email to