- A Cookbook Topic: "Delay", "WaitUntil" and "Let's see actions"

From: Marco Ciot <"Marco>
Date: Fri, 12 May 2006 10:29:55 +0200

----boundary-LibPST-iamunique-2112026358_-_-
Content-type: text/plain

Hey Alexander

Just discovered your long note and would like to add my state of knowledge.

> The real problem here is that BlackBox doesn't support multitasking.
  What you are trying to do is suspend a task for some time while the
  rest of the BlackBox keeps on living. This is simply not supported.

FALSE: BB is very much multitasking, but doesn't do preemption of tasks. The
philosophy behind "cooperative" multitasking is that every task takes care
of this fact and returns control asap to the system, by simply not blocking
unneccesarily.
A task can very much suspend for some time, by simply using Services.DoLater
in order to proceed at the desired time.

> This would require re-entering HostMenus.Loop somehow, and then
  leaving it after some time. No such mechanism exist, because
  HostMenus.Loop procedure is not even published.

Why mess with HostMenus, at all.
Services is the module implementing the multitasking.
HostMenus.Loop is responsible for the user interaction which I believe is
hardly relevant for (background) tasks.

> It's a pity that such great non-modal user interface turns out to be
  so modal to its different tasks. You either grab total control over
  application or must release it and hope it will remember about you
  after some time. Nothing in-between. I think it shouldn't be that
  way in a message-driven application.

I think, here you are right!
The problem is, that user interaction has too much "priority".
But the solution is simple as the design is good.
I believe this is just a "Fehler" (mistake in german ~= "misser"), i.e.
something is missing, only, and not completely wrong.
The problem is, that most tracking functions are implemented with busy loops
calling Input. (By the way there exists a way of implementing the same
functions without busy loops!)
If inside of all these busy loops a call to Services.actionHook.Step is
added, the system very much keeps performing the background tasks even
during user interaction.
However, the display is not neccesarily updated, i.e. the cube and the clock
will run, but the update (which is a delayed update) will not be performed
and thus you don't see much effect.
According to me this is no problem as the user while interaction should
focus on other things than a turning cube ;)

> There is not even a good waiting sequence to implement, which I keep
  complaining about. If you need to track mouse movements, you will
  load CPU up to 100% and nothing will move in the background. You
  cannot go idle until mouse movement event occurs, you must keep
  asking for its coordinates until a button is released. That's awful,
  but that's what BlackBox do everywhere.

Exactly. But not so dramatic, anyway.
I think it is very much possible to implement the tracking handling without
any loops at all, though.
The problem indeed is that you shouldn't have the option to ask for the
coordinates.
(The coordinates are passed to you with the message.)
I believe that the Ports.Input procedure is a dinosaur from the old Ceres
Oberon.
Therefore I pleed that Ports.Input itself must call Services.actionHook.Step
and after that Kernel.Sleep in order to wait at lease 20 ms before doing
anything else, i.e. reading the new mouse coordinates from the windows api.
This tribute would solve the BIG problem.

Unfortunately Ports.Input might also be called by Actions and thus would
mean a cascaded call to Services.actionHook.Step, which meens a problem.
Therefore Step requires some modification, too.

As I have done my modification on BB 1.4 I will first adapt it to 1.5 and
then publish it.

Regards
Marco Ciot

--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy



----boundary-LibPST-iamunique-2112026358_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIEhleSBBbGV4YW5kZXJccGFyDQpccGFyDQpKdXN0
IGRpc2NvdmVyZWQgeW91ciBsb25nIG5vdGUgYW5kIHdvdWxkIGxpa2UgdG8gYWRkIG15IHN0YXRl
IG9mIGtub3dsZWRnZS5ccGFyDQpccGFyDQo+ICBUaGUgcmVhbCBwcm9ibGVtIGhlcmUgaXMgdGhh
dCBCbGFja0JveCBkb2Vzbid0IHN1cHBvcnQgbXVsdGl0YXNraW5nLlxwYXINCiAgV2hhdCB5b3Ug
YXJlIHRyeWluZyB0byBkbyB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kIHRoYXQgUG9ydHMuSW5wdXQgaXRzZWxmIG11
c3QgY2FsbCBTZXJ2aWNlcy5hY3Rpb25Ib29rLlN0ZXBccGFyDQphbmQgYWZ0ZXIgdGhhdCBLZXJu
ZWwuU2xlZXAgaW4gb3JkZXIgdG8gd2FpdCBhdCBsZWFzZSAyMCBtcyBiZWZvcmUgZG9pbmdccGFy
DQphbnl0aGluZyBlbHNlLCBpLmUuIHJlYWRpbmcgdGhlIG5ldyBtb3VzZSBjb29yZGluYXRlcyBm
cm9tIHRoZSB3aW5kb3dzIGFwaS5ccGFyDQpUaGlzIHRyaWJ1dGUgd291bGQgc29sdmUgdGhlIEJJ
RyBwcm9ibGVtLlxwYXINClxwYXINClVuZm9ydHVuYXRlbHkgUG9ydHMuSW5wdXQgbWlnaHQgYWxz
byBiZSBjYWxsZWQgYnkgQWN0aW9ucyBhbmQgdGh1cyB3b3VsZFxwYXINCm1lYW4gYSBjYXNjYWRl
ZCBjYWxsIHRvIFNlcnZpY2VzLmFjdGlvbkhvb2suU3RlcCwgd2hpY2ggbWVlbnMgYSBwcm9ibGVt
LlxwYXINClRoZXJlZm9yZSBTdGVwIHJlcXVpcmVzIHNvbWUgbW9kaWZpY2F0aW9uLCB0b28uXHBh
cg0KXHBhcg0KQXMgSSBoYXZlIGRvbmUgbXkgbW9kaWZpY2F0aW9uIG9uIEJCIDEuNCBJIHdpbGwg
Zmlyc3QgYWRhcHQgaXQgdG8gMS41IGFuZFxwYXINCnRoZW4gcHVibGlzaCBpdC5ccGFyDQpccGFy
DQpSZWdhcmRzXHBhcg0KTWFyY28gQ2lvdFxwYXINClxwYXINCi0tLSBCbGFja0JveFxwYXINCi0t
LSBzZW5kIHN1YmplY3QgSEVMUCBvciBVTlNVQlNDUklCRSB0byBibGFja2JveEBvYmVyb24uY2hc
cGFyDQpccGFyDQp9


----boundary-LibPST-iamunique-2112026358_-_---
Received on Fri May 12 2006 - 10:29:55 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:28:01 UTC