Responsiveness during longer computational processes

APL-related discussions - a stream of APL consciousness.
Not sure where to start a discussion ? Here's the place to be
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !

Re: Responsiveness during longer computational processes

Postby StefanoLanzavecchia on Fri Sep 24, 2010 8:48 am

There's a fundamental difference.

If you define
[]NA 'I kernel32|SomeFunction& I'
and if you have

[0] foo x
...
[4] SomeFunction 20
if you call foo&1, the APL thread, which is executed inside the cooperative environment of the interpreter, at line 4 becomes an OS thread freeing the GUI thread and keeping your application responsive.

If, instead, you define
[]NA 'I kernel32|SomeFunction I'
and have a foo

[0] foo x
...
[4] SomeFunction&20
if you call foo from the GUI thread (thread 0 in most APL applications), when you spawn a new thead in line 4 the thread will block the whole interpreter because it's an APL thread executing an external function and the interpreter cannot switch APL thread while executing SomeFunction.

That's why I recommend the first usage pattern, if the way you designed your code permits you to run the whole "foo" in parallel, because that way when it gets to execute SomeFunction it won't block the entire interpreter.
User avatar
StefanoLanzavecchia
 
Posts: 84
Joined: Fri Oct 03, 2008 9:37 am

Re: Responsiveness during longer computational processes

Postby Budgie on Fri Sep 24, 2010 9:19 am

How would you do this for a .NET method?
Jane
User avatar
Budgie
 
Posts: 36
Joined: Thu Nov 26, 2009 9:22 am
Location: Beckenham

Re: Responsiveness during longer computational processes

Postby StefanoLanzavecchia on Fri Sep 24, 2010 9:25 am

I would ask John Daintree, I am afraid... As far as I can tell, there's no way right now. And I'd love to be proven wrong.
User avatar
StefanoLanzavecchia
 
Posts: 84
Joined: Fri Oct 03, 2008 9:37 am

Re: Responsiveness during longer computational processes

Postby PhilGray on Fri Sep 24, 2010 9:34 am

Stefano .. Perfect !
Problem solved ... perfect solution, much appreciated.

I think this should be included in the ⎕NA section of the manual, as it is IMO very important to know .
... I did read the manual BTW !
;-)
PhilGray
 
Posts: 50
Joined: Sat Mar 13, 2010 7:55 pm

Re: Responsiveness during longer computational processes

Postby JohnD|Dyalog on Fri Oct 08, 2010 1:10 pm

Budgie wrote:How would you do this for a .NET method?


Dyalog always creates an OS (or .Net) thread for .Net functions on new APL threads. So, any .Net function executed from a new APL thread will allow other APL threads to run concurrently.
User avatar
JohnD|Dyalog
 
Posts: 66
Joined: Wed Oct 01, 2008 9:35 am

Previous

Return to APL Chat

Who is online

Users browsing this forum: No registered users and 1 guest