New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
incorrect return value for threads::join() #8174
Comments
From wendigo@jabberwock.orgThis is a bug report for perl from wendigo@jabberwock.org, It looks like the threads::join() function is returning undef when it should What the manpage says: $thread->join What threads v1.05 actually does: -- sub foo { for my $val (0..2) { foreach my $t (threads->list) { 1 returning 0 Flags: Site configuration information for perl v5.8.7: Configured by wendigo at Mon Oct 24 11:24:44 EDT 2005. Summary of my perl5 (revision 5 version 8 subversion 7) configuration: Locally applied patches: @INC for perl v5.8.7: Environment for perl v5.8.7: |
From robin@cpan.orgBelieve it or not, this is (almost) a documented feature. The The context (scalar or list) of the thread creation is also the (My "almost" is because this should really say "void, scalar or list".) Your code is calling create() in void context, so join() isn't for my $val (0..2) { then it works as expected. Of course this is totally insane, but there you go. Robin |
The RT System itself - Status changed from 'new' to 'open' |
From @lizmatAt 11:07 PM +0000 10/30/05, Robin Houston wrote:
Well, consider how you would communicate the context in which the More exactly: there could be a check for "wantarray" in the beginning So I think the behaviour is maybe a little surprising, there is Now in an ideal world you could maybe set up different return values Liz |
From @rgarciaRobin Houston wrote:
Thanks, changed as #25912. |
From robin@cpan.org
I understand that the context needs to be determined in advance, Suppose you want the thread to be in void context, but you also threads->new(\&foo); # void context! which might not work, because some other thread might create a my ($thread) = threads->new(\&bar); A more sensible approach, IMO, would be to specify the context my $thread1 = threads->create(\&foo, 'void'); but I fear it may be too late to change this. Robin |
From @lizmatAt 9:50 AM +0000 10/31/05, Robin Houston wrote:
I guess the alternative would have been to only allow a single scalar
If you need the thread to be joined in void context, just join it in
Indeed, because 'void' and 'list' would just be passed as parameters I think that actually even more context would have been more Liz |
From robin@cpan.orgOn Mon, Oct 31, 2005 at 11:05:32AM +0200, Elizabeth Mattijsen wrote:
I agree, that would have been fine. I have no idea who made this
It won't cause the sub to be *called* in void context.
That was a very bad choice of example syntax. Sorry! Robin |
From @lizmatAt 10:31 AM +0000 10/31/05, Robin Houston wrote:
Maybe this would help as a temporary fix: sub threads::create_to_join_as_list { (shift->create( @_ ))[0] }; my $thread = threads->create_to_join_as_list( sub { (1,2,3) } ); print "thread = $thread\n"; my @result = $thread->join; print "result = @result\n"; Liz |
From wendigo@pobox.comAn entity claiming to be Robin Houston (robin@cpan.org) wrote: Ok, that explains it. : I don't know if it's necessarily insane. If you want a thread executed in An entity claiming to be Elizabeth Mattijsen via RT (perlbug-followup@perl.org) wrote: I think an approach like this is probably best. Although, I am partial to -- |
From guest@guest.guest.xxxxxxxx
This is now addressed with change #28291. |
From @jdheddenOn Thu May 25 06:57:05 2006, guest wrote:
Confirmed. This bug is fixed. |
@cpansprout - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#37564 (status was 'resolved')
Searchable as RT37564$
The text was updated successfully, but these errors were encountered: