October 19, 2010 Re: First big PITA in reallife D project | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | Steven Schveighoffer wrote:
> On Tue, 19 Oct 2010 08:35:09 -0400, Stephan <spam@extrawurst.org> wrote:
>>
>> Thanks for the reply and that you gonna take a look. I added the relation of bug http://d.puremagic.com/issues/show_bug.cgi?id=4344 to the bug aswell because it reallys seems to have the same underlying root.
>
> I fixed both with the suggested update in 4344. I also found a race condition on Linux that as far as I know was never reported.
>
> See changeset http://www.dsource.org/projects/phobos/changeset/2107
>
> That was an easy one :)
Awesome, thanks for taking care of this one.
| |||
October 19, 2010 Re: First big PITA in reallife D project | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Stephan Attachments:
| I doubt a new version of dmd will be out until November at the earliest, as there is no dmd beta out at the moment. In the mean time, you should be able to download the latest source code of phobos at http://www.dsource.org/projects/phobos/changeset/head/trunk?old_path=%2F&format=zip and build the code. I'm not familiar with dmd under windows, but I believe you can just replace the phobos .lib/.dll/.whateverextension file with the one you built. On Tue, Oct 19, 2010 at 10:02 AM, Stephan <spam@extrawurst.org> wrote: > On 19.10.2010 15:27, Steven Schveighoffer wrote: > >> On Tue, 19 Oct 2010 08:35:09 -0400, Stephan <spam@extrawurst.org> wrote: >> >>> >>> Thanks for the reply and that you gonna take a look. I added the relation of bug http://d.puremagic.com/issues/show_bug.cgi?id=4344 to the bug aswell because it reallys seems to have the same underlying root. >>> >> >> I fixed both with the suggested update in 4344. I also found a race condition on Linux that as far as I know was never reported. >> >> See changeset http://www.dsource.org/projects/phobos/changeset/2107 >> >> That was an easy one :) >> >> -Steve >> > > Awesome, thank you. > Is there a new release planned anytime soon that includes the patch ? > > - Stephan > | |||
October 19, 2010 Re: First big PITA in reallife D project | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | Andrei Alexandrescu Wrote:
> Terminating threads has always been iffy in all languages that use native threads. I've discussed with Sean a couple of times about ways to define a little protocol and API for orderly thread termination. We need something like a callback mechanism - atShutdown().
Why? Just call delete on the thread object and in destructor do everything you want to put in atShutdown.
| |||
October 19, 2010 Re: First big PITA in reallife D project | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On 10/19/10 13:59 CDT, Kagamin wrote:
> Andrei Alexandrescu Wrote:
>
>> Terminating threads has always been iffy in all languages that use
>> native threads. I've discussed with Sean a couple of times about
>> ways to define a little protocol and API for orderly thread
>> termination. We need something like a callback mechanism -
>> atShutdown().
>
> Why? Just call delete on the thread object and in destructor do
> everything you want to put in atShutdown.
The problem with that is that it scales bad when you have many threads - the last thread stopped would have to wait for all others to stop.
Andrei
| |||
October 19, 2010 Re: First big PITA in reallife D project | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On 19-ott-10, at 19:17, Andrei Alexandrescu wrote: > On 10/19/10 11:07 CDT, FeepingCreature wrote: >> On 19.10.2010 13:33, Stephan wrote: >>> BUT it wont work like that. AFTER i stopped all other threads some >>> strange behavior of druntime makes every creation of an >>> InternetAddress instance (internally trying to resolve host) >>> impossible (throws an exception). Additionally even if the Internet >>> Addresses were created upfront the TcpSockets wont connect but >>> throw. >> >> Terminating threads has always been iffy in D. > > Terminating threads has always been iffy in all languages that use native threads. I've discussed with Sean a couple of times about ways to define a little protocol and API for orderly thread termination. We need something like a callback mechanism - atShutdown(). As feep wrote using thread pools is often better. With D1/tango one can use blip (whose release is hopefully just a few days away) it becomes very nice to do. Unfortunately this is not for Stephan, as most likely it will not work on windows, because I used and developed it only on mac/linux, and windows will require some porting. Anyway checking several addresses in parallel becomes simply: import blip.parallel.smp.PLoopHelpers; import blip.io.Socket; //... foreach(addr;pLoopArray(adressesToCheck){ auto s=BasicSocket(addr,"80"); // do stuff } and this will use optimally all processors of your computer, and will use libev to never block waiting for input... Also making a server is not so difficult as shown by http://github.com/fawzi/blip/blob/master/tests/EchoServer.d the checking operation can spawn new tasks without problems. Fawzi | |||
October 22, 2010 Re: First big PITA in reallife D project | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Kagamin | Kagamin Wrote:
> Andrei Alexandrescu Wrote:
>
> > Terminating threads has always been iffy in all languages that use native threads. I've discussed with Sean a couple of times about ways to define a little protocol and API for orderly thread termination. We need something like a callback mechanism - atShutdown().
>
> Why? Just call delete on the thread object and in destructor do everything you want to put in atShutdown.
Thread objects are tracked by the runtime. If you explicitly delete them, expect a segfault. I suppose I could use a pimpl approach to avoid this, but it would be a tad tricky (Thread.getThis() for example). More appropriate is to use a non-shared static dtor to signal thread shutdown, which is basically how OwnerTerminated works anyway. It's just taken care of for you.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply