|
From: <HBB...@t-...> - 2007-05-07 19:17:53
|
Timothée Lecomte wrote:
> 1st solution, as suggested previously = use two processes:
> - this is the design of the x11 terminal. I don't like it, because I
> find complicated to have to handle two processes and their
> inter-communication where we really have one program (one task).
I don't really believe inter-communication between threads to be any
easier than inter-communication between processes, in the long run.
More efficient it may be, but it's not easier. You basically pay for
the extra speed by extra requirements on careful coding.
> 3rd solution = use one thread only (the most ambitious)
> - the one and only thread is an event loop.
> - "a char arrived on stdin" is handled as an event (this is natural,
> isn't it?), and passed to readline
> - the event loop is actually the GUI loop, just extended to watch stdin
> in addition to window events
That's pretty much the way the Windows native terminal has been doing
things since day 1 (and in a pretty nasty way, too, overriding the
<stdio.h> functions with macros of our own making). Which means a bit
of synergy might be achievable if you go this way.
> Currently, we have:
> while( readline(); do_line(); ) {};
>
> Instead we would have an event loop, with the following callbacks:
> data_is_available_in_stdin() {rl_callback_read_char ();}
> line_is_completed() {do_line();}
Not necessarily. It's possible to lace the GUI event handling into the
readline character input function instead.
|