Debugging D shared libraries

Russel Winder via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 22 07:43:07 PDT 2015


On Sun, 2015-09-20 at 07:49 +0000, rom via Digitalmars-d-learn wrote:
> 
[…]
> > works entirely fine. However the "parallel" code:
> > 
> >     extern(C)
> >     double parallel(const int n, const double delta) {
> >       Runtime.initialize();
> >       const pi = 4.0 * delta * taskPool.reduce!"a + b"(
> >           map!((int i){ immutable x = (i - 0.5) * delta; return 
> > 1.0 / (1.0 + x * x); })(iota(1, n + 1)));
> >       Runtime.terminate();
> >       return pi;
> >     }
> > 
[…]
> 
> Isn't it simply that when doing some work asynchronously, as with 
> task pool, work is being done in other threads than the main. All 
> the while, you're killing the Runtime. The fact that when 
> removing  Runtime.terminate makes the code work might support 
> that explanation.

I am not sure that can be the case per se as reduce only uses threads
internally, the task pool operations should be complete by the time pi
is initialized. On the other hand there might be a lock contention
between a quiescent default task pool and the terminate code.

The code is now moved on a bit from the above, and it works sufficient
for the task at hand. This isn't production code so it doesn't have to
be quite as good and correct as maybe it should be.
 
-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150922/1db7d364/attachment.sig>


More information about the Digitalmars-d-learn mailing list