Thread overview | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
April 14, 2012 Re: Thread join behaviour | ||||
---|---|---|---|---|
| ||||
On 04/14/12 18:04, Russel Winder wrote:
> I thought the following would terminate gracefully having printed 0..9
> in some (random) order:
>
> #! /usr/bin/env rdmd
>
> import std.algorithm ;
> import std.range ;
> import std.stdio ;
> import core.thread ;
>
> int main ( immutable string[] args ) {
> auto threads = map ! ( ( int a ) {
> void delegate ( ) f ( ) {
> return delegate ( ) { writeln ( a ) ; } ;
> }
> return new Thread ( f ) ;
> } ) ( iota ( 10 ) ) ;
> foreach ( t ; threads ) { t.start ( ) ; }
> foreach ( t ; threads ) { t.join ( ) ; }
> return 0 ;
> }
>
> However, this does not happen, at least with 2.059 on Linux as per Debian Unstable. Instead I get:
>
> 1
> 2
> 4
> 5
> 8
> 3
> 7
> 6
> 9
> 0
> core.thread.ThreadException@src/core/thread.d(906): Unable to join thread
> ----------------
> /tmp/.rdmd-1000/home/users/russel/Progs/OddsByLanguage/D/Odds/initializingWithAMap.d.9532BBED12C814F25F173A9AEAB96D0D(_Dmain+0x83) [0x425edb]
> /tmp/.rdmd-1000/home/users/russel/Progs/OddsByLanguage/D/Odds/initializingWithAMap.d.9532BBED12C814F25F173A9AEAB96D0D(extern (C) int rt.dmain2.main(int, char**).void runMain()+0x17) [0x429bab]
> /tmp/.rdmd-1000/home/users/russel/Progs/OddsByLanguage/D/Odds/initializingWithAMap.d.9532BBED12C814F25F173A9AEAB96D0D(extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate())+0x23) [0x42952b]
> /tmp/.rdmd-1000/home/users/russel/Progs/OddsByLanguage/D/Odds/initializingWithAMap.d.9532BBED12C814F25F173A9AEAB96D0D(extern (C) int rt.dmain2.main(int, char**).void runAll()+0x3d) [0x429bf9]
> /tmp/.rdmd-1000/home/users/russel/Progs/OddsByLanguage/D/Odds/initializingWithAMap.d.9532BBED12C814F25F173A9AEAB96D0D(extern (C) int rt.dmain2.main(int, char**).void tryExec(scope void delegate())+0x23) [0x42952b]
> /tmp/.rdmd-1000/home/users/russel/Progs/OddsByLanguage/D/Odds/initializingWithAMap.d.9532BBED12C814F25F173A9AEAB96D0D(main+0xd3) [0x4294c3]
> /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xfd) [0x7f1ed17f8ead]
> ----------------
>
> I think I must be having a dumb moment as my reaction continues to be WTF.
'threads' is a (lazy) range;
auto threads = array(map ! ( ( int a ) {
void delegate ( ) f ( ) {
return delegate ( ) { writeln ( a ) ; } ;
}
return new Thread ( f ) ;
} ) ( iota ( 10 ) )) ;
artur
|
April 15, 2012 Re: Thread join behaviour | ||||
---|---|---|---|---|
| ||||
Attachments:
| On Sat, 2012-04-14 at 23:25 +0200, Artur Skawina wrote: [...] > > 'threads' is a (lazy) range; > > auto threads = array(map ! ( ( int a ) { > void delegate ( ) f ( ) { > return delegate ( ) { writeln ( a ) ; } ; > } > return new Thread ( f ) ; > } ) ( iota ( 10 ) )) ; > Sadly this is not going to work: /home/users/russel/lib.Linux.x86_64/DMD2/bin64/../../src/phobos/std/traits.d(1482): Error: void does not have a default initializer /home/users/russel/lib.Linux.x86_64/DMD2/bin64/../../src/phobos/std/traits.d(1493): Error: template instance std.traits.hasIndirections!(Thread).Impl!(void[168LU]) error instantiating /home/users/russel/lib.Linux.x86_64/DMD2/bin64/../../src/phobos/std/array.d(143): instantiated from here: hasIndirections!(Thread) /home/users/russel/lib.Linux.x86_64/DMD2/bin64/../../src/phobos/std/array.d(143): Error: template instance std.traits.hasIndirections!(Thread) error instantiating /home/users/russel/lib.Linux.x86_64/DMD2/bin64/../../src/phobos/std/array.d(243): Error: template instance std.array.blockAttribute!(Thread) error instantiating /home/users/russel/lib.Linux.x86_64/DMD2/bin64/../../src/phobos/std/array.d(194): instantiated from here: arrayAllocImpl!(false,Thread[],uint) /home/users/russel/lib.Linux.x86_64/DMD2/bin64/../../src/phobos/std/array.d(42): instantiated from here: uninitializedArray!(Thread[],uint) ./initializingWithAMap.d(9): instantiated from here: array!(Result) /home/users/russel/lib.Linux.x86_64/DMD2/bin64/../../src/phobos/std/array.d(194): Error: template instance std.array.arrayAllocImpl!(false,Thread[],uint) error instantiating /home/users/russel/lib.Linux.x86_64/DMD2/bin64/../../src/phobos/std/array.d(42): instantiated from here: uninitializedArray!(Thread[],uint) ./initializingWithAMap.d(9): instantiated from here: array!(Result) /home/users/russel/lib.Linux.x86_64/DMD2/bin64/../../src/phobos/std/array.d(42): Error: template instance std.array.uninitializedArray!(Thread[],uint) error instantiating ./initializingWithAMap.d(9): instantiated from here: array!(Result) ./initializingWithAMap.d(9): Error: template instance std.array.array!(Result) error instantiating -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder |
April 15, 2012 Re: Thread join behaviour | ||||
---|---|---|---|---|
| ||||
On 04/15/12 15:55, Russel Winder wrote:
> On Sat, 2012-04-14 at 23:25 +0200, Artur Skawina wrote: [...]
>>
>> 'threads' is a (lazy) range;
>>
>> auto threads = array(map ! ( ( int a ) {
>> void delegate ( ) f ( ) {
>> return delegate ( ) { writeln ( a ) ; } ;
>> }
>> return new Thread ( f ) ;
>> } ) ( iota ( 10 ) )) ;
>>
>
> Sadly this is not going to work:
works here, when written as
auto threads = array(map ! ( function ( int a ) {
void delegate ( ) f ( ) {
return delegate ( ) { writeln ( a ) ; } ;
}
return new Thread ( f ) ;
} ) ( iota ( 10 ) )) ;
(my old GDC needs the explicit "function", no idea if newer
frontends still require that)
artur
|
April 15, 2012 Re: Thread join behaviour | ||||
---|---|---|---|---|
| ||||
Attachments:
| On Sun, 2012-04-15 at 16:04 +0200, Artur Skawina wrote: [...] > (my old GDC needs the explicit "function", no idea if newer > frontends still require that) OK, works for me with GDC as well, DMD is broken! I'll file a bug report. -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder |
April 15, 2012 Re: Thread join behaviour | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russel Winder | Le 15/04/2012 20:40, Russel Winder a écrit :
> On Sun, 2012-04-15 at 16:04 +0200, Artur Skawina wrote: [...]
>> (my old GDC needs the explicit "function", no idea if newer
>> frontends still require that)
>
> OK, works for me with GDC as well, DMD is broken! I'll file a bug report.
>
It works here (DMD 2.058 win32), even without "function".
|
April 16, 2012 Re: Thread join behaviour | ||||
---|---|---|---|---|
| ||||
Posted in reply to Somedude Attachments:
| On Sun, 2012-04-15 at 23:36 +0200, Somedude wrote: [...] > It works here (DMD 2.058 win32), even without "function". It also works for me with 2.058 on x86_64 Linux. So the conclusion is that 2.059 is broken. I'll update the issue I set up for this. -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder |
April 16, 2012 Re: Thread join behaviour | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russel Winder | Le 15/04/2012 20:40, Russel Winder a écrit :
> On Sun, 2012-04-15 at 16:04 +0200, Artur Skawina wrote: [...]
>> (my old GDC needs the explicit "function", no idea if newer
>> frontends still require that)
>
> OK, works for me with GDC as well, DMD is broken! I'll file a bug report.
>
Did you file a bug report ? If yes, which number ? This is an annoying regression in my opinion.
|
April 17, 2012 Re: Thread join behaviour | ||||
---|---|---|---|---|
| ||||
Posted in reply to Somedude Attachments:
| On Mon, 2012-04-16 at 21:03 +0200, Somedude wrote: [...] > Did you file a bug report ? If yes, which number ? This is an annoying regression in my opinion. Issue 7919 http://d.puremagic.com/issues/show_bug.cgi?id=7919 -- Russel. ============================================================================= Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder@ekiga.net 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel@winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder |
April 17, 2012 Re: Thread join behaviour | ||||
---|---|---|---|---|
| ||||
Posted in reply to Russel Winder | Le 17/04/2012 08:40, Russel Winder a écrit :
> On Mon, 2012-04-16 at 21:03 +0200, Somedude wrote:
> [...]
>
> Issue 7919
>
> http://d.puremagic.com/issues/show_bug.cgi?id=7919
>
Thanks.
|
Copyright © 1999-2021 by the D Language Foundation