Ouch! Igor, chill!
Igor Kovalenko <kovalenko@attbi.com> wrote:
IK > “Bill Caroselli” <qtps@earthlink.net> wrote in message
IK > news:bh0nn4$m5i$1@inn.qnx.com…
My philosophy is that GUI programs are simply that User Interfaces to
some other program that actually does the work. The GUI program should
not be a workhorse itself.
IK > There’s a world of difference between a ‘philosophy’ and a usable GUI
IK > application. Users’ behavior usually does not fit into philosophies that you
IK > want to impose on them. They are unpredictable and irrational. And easily
IK > irritable. Whatever they do, they expect an application to behave in
IK > ‘natural’ and ‘intuitive’ way. Having to wait for completion of anything
IK > before they can do something else is the last thing they expect.
I completely agree. I don’t know what I said that made you think I
didn’t.
When someone clicks somewhere on the screen the GUI program should send
a message to some API. When some external status changes it should
send a Pulse to the GUI program. The GUI program should then issue
an API status request to the real workhorse program to get the current
status and then update its screen accordingly.
This eliminates the need for the GUI program to be multi-threaded.
IK > Great. You send a request that requires long enough time to execute, it
IK > takes too long, user gets annoyed, “damn, i want to cancel that”… oops,
IK > you can’t cancel until you get response back from server because you’re
IK > blocked. Just relax, sit and look at the hourglass… ah, too bad.
IK > Meanwhile, another application popped up (because some external event has
IK > caused it to gain focus, or you just did it yourself out of boredom)…now
IK > you do something with it quickly, it closes (exits or you minimize it) and
IK > guess what? Right, you’ve got yourself a nice (white or otherwise filled
IK > with bogus stuff) rectange underneath the area previously covered by that
IK > app in the middle of your first application’s window… that application is
IK > still executing that damned request so it is blocked and can’t handle the
IK > EXPOSE events (i.e., can’t re-render its own widgets). Ok, maybe you did not
IK > close that second window. Maybe you want to move it around? The ‘trace’ of
IK > rectangles that it will leave will look really artistic…
IK > I have seen way too many crappy GUI applications like that, especially in
IK > QNX. Don’t even want to waste energy arguing…
OK. I get it. I’m NOT addressing a situation where the user clicks
on a button to send a 100 MB file to some other host and then they
decide they want to CANCLE it. Here you’re probibly neededing/
wanting threads.
The original poster was asking about process control. Robotics, I
think. I was addressing a Real-time Process Control solution.
In all of my designs there is a high priority process that controls whatever. It has an interrupt handler to know the status of hardware and it has one or more threads for processing API requests from clients. Processing an API request for a client is never a matter of:
Receive Request
Do the Request
Reply to the Request
That is NOT REAL-TIME!
The server process is more like:
Receive request (client’s request include a channel to Pulse to)
Validate the requst (is it a valid thing to request)
Reply to the client (OK, I’ll let you know, or Forget about it!)
The server is then able to process the request in a thread all it’s
own. When the request either successfully finishes or fails the
server sends a Pulse to the original client.
The Client sends a Status Query Request to the server.
The server immediately replies with the status, including that the
last request succeded or failed because of “XXXX”.
This is a very real-time approach to process control.
This way the photon program is just sending mouse clicks to the
controlling process via the API and updating the screen when it
receives a Pulse.
But
there are MANY other advantages to this approach too. I.E. There
may be more than one Control Interface to some underlying process. And
that control process may be on a remote node.
IK > You’re confusing things. Nobody said anything about a control process.
IK > Whatever that is, and whether it is local or remote, it is irrelevant. The
IK > ‘interface’ piece (i.e., the part dealing PURELY with interfacing the user)
IK > by itself needs to be multithreaded if you ever hope to provide any decent
IK > level of user experience. The only other alternative is splitting ‘lenghty’
IK > operations into chunks and handling them one by one, as Photon docs suggest.
IK > Of course that in the end is nothing more than a rather lame
IK > pseudo-multithreading that requires extra work and attention from you and
IK > does not work too well anyway. The only reason they had to come up with a
IK > design marvel like that is that the Photon libs were not thread-safe.