[BLACKBOX] [Fwd: Re: [BLACKBOX] Long running command and Dialog.ShowStatus]

From: [at]} <Robert>
Date: Thu, 3 Dec 2009 22:34:08 +0000

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

-------- Original Message --------
Subject: Re: [BLACKBOX] Long running command and Dialog.ShowStatus
Date: Thu, 03 Dec 2009 22:07:05 +0000
From: Robert <robert.campbell_{([at]})nowhere.xy
To: georgy.jikia{([at]})nowhere.xy
References: <
DD798FE898174BA1A9A8B95D02CED25F{([at]})nowhere.xy
<5E2F0C70DD6F49BAB2E95DFA7D73ED00{([at]})nowhere.xy
<b1b4da1a0912031205m26f06589md0ae75210e634553{([at]})nowhere.xy

Georgy

I have used this approach myself.

Two comments:

1) There is an overhead, but it is a fixed overhead, not a fraction. It is a
coincidence that it is 50 % in this example (on my machine, a single core AMD
chip). If you increase the loop from 10000000 to 15000000 the utilisation
increases to 75 %, and if you increase it further the utilisation approaches 100
%. So for very big sums (minutes to hours to days) the overhead can be a
negligible fraction.

2) But the logic involved in using Actions can be very awkward. If the task is a
simple loop, as in this example, it is not too bad. But if the task is several
nested loops, and you need to be able to interrupt it partly through the inner
loop, it is less easy (but possible, and sometimes necessary).

Surely these problems (apparent hanging of BlackBox, and the fact that
Ctrl-Break does not work as advertised) can and should be solved at a lower
level than imposing lots of awkward logic into every application?


Regards

Robert




Georgy Jikia wrote:
> You can also use background processing service using Services.Action:
>
> MODULE TestLong;
> IMPORT Dialog, Services, Strings;
> TYPE LongFunc = POINTER TO RECORD (Services.Action)
> i: INTEGER;
> END;
> VAR func: LongFunc;
> PROCEDURE (func: LongFunc) Do;
> VAR j: INTEGER; s: ARRAY 20 OF CHAR;
> BEGIN
> INC(func.i);
> FOR j := 0 TO 10000000 DO
> END;
> Strings.IntToString(func.i, s);
> Dialog.ShowStatus("msg " + s);
> IF func.i < 300 THEN
> Services.DoLater(func, Services.now)
> ELSE
> func := NIL;
> END;
> END Do;
>
> PROCEDURE Interrupt*;
> VAR res: INTEGER;
> BEGIN
> Services.RemoveAction(func);
> Dialog.GetOK("interrupted", "", "", "", {Dialog.ok}, res);
> END Interrupt;
>
> PROCEDURE DoLong*;
> BEGIN
> NEW(func);
> Services.DoLater(func, Services.now);
> END DoLong;
> END TestLong.
>
> ^QTestLong.DoLong
> ^QTestLong.Interrupt
>
> Chris, that's probably what you were suggesting?
> This calculation takes more time however, as only 50% CPU is used by BlackBox.
>
> Regards,
> Georgy
>
>
> ----
> To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy
>
>
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 9.0.709 / Virus Database: 270.14.91/2542 - Release Date: 12/03/09 07:32:00
>


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-1708161508_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIC0tLS0tLS0tIE9yaWdpbmFsIE1lc3NhZ2UgLS0t
LS0tLS1ccGFyDQpTdWJqZWN0OiBSZTogW0JMQUNLQk9YXSBMb25nIHJ1bm5pbmcgY29tbWFuZCBh
bmQgRGlhbG9nLlNob3dTdGF0dXNccGFyDQpEYXRlOiBUaHUsIDAzIERlYyA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S0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tXHBhcg0KPiBccGFyDQo+IFxwYXIN
Cj4gTm8gdmlydXMgZm91bmQgaW4gdGhpcyBpbmNvbWluZyBtZXNzYWdlLlxwYXINCj4gQ2hlY2tl
ZCBieSBBVkcgLSB3d3cuYXZnLmNvbSBccGFyDQo+IFZlcnNpb246IDkuMC43MDkgLyBWaXJ1cyBE
YXRhYmFzZTogMjcwLjE0LjkxLzI1NDIgLSBSZWxlYXNlIERhdGU6IDEyLzAzLzA5IDA3OjMyOjAw
XHBhcg0KPiBccGFyDQpccGFyDQpccGFyDQotLS0tXHBhcg0KVG8gdW5zdWJzY3JpYmUsIHNlbmQg
YSBtZXNzYWdlIHdpdGggYm9keSAiU0lHTk9GRiBCTEFDS0JPWCIgdG8gTElTVFNFUlZATElTVFMu
T0JFUk9OLn19AGhlIHV0aQ==
----boundary-LibPST-iamunique-1708161508_-_---
Received on Thu Dec 03 2009 - 23:34:08 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:30:40 UTC