Changeset 20091 for docs/Perl6/Spec

Show
Ignore:
Timestamp:
03/09/08 23:18:55 (9 months ago)
Author:
buchetc
Message:

[t/spec] another coro example

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • docs/Perl6/Spec/Concurrency.pod

    r20085 r20091  
    300300=head1 Threads 
    301301 
     302All outside of a thread defined variables are 
     303shared and transactional variables by default 
     304 
     305Program will wait for _all_ threads. 
     306Unjoined threads will be joined at the beginning of the END 
     307block batch of the parent thread that spawned them 
     308 
    302309=head2 Thread creation 
    303310 
     
    311318 
    312319 
    313 =head2 Thread attributes 
     320=head2 Thread status and attributes 
    314321 
    315322=over 
     
    341348 
    342349the CC currently running in that thread 
     350 
     351 
     352=item wake_on_readable, wake_on_writable, wake_on 
     353 
     354TODO: IO objects and containers gets concurrency love! 
     355 
     356 - $obj.wake_on_either_readable_or_writable_or_passed_time(3); # fixme fixme 
     357 - $obj.wake_on:{.readable} # busy wait, probably 
     358 
     359    my @a is Array::Chan = 1..Inf; 
     360    async { @a.push(1) }; 
     361    async { @a.blocking_shift({ ... }) }; 
     362    async { @a.unshift({ ... }) }; 
     363 
    343364 
    344365=back 
     
    437458 
    438459=back 
    439  
    440 =head2 Thread status 
    441  
    442  -IO objects and containers gets concurrency love! 
    443     - $obj.wake_on_readable 
    444     - $obj.wake_on_writable 
    445     - $obj.wake_on_either_readable_or_writable_or_passed_time(3); # fixme fixme 
    446     - $obj.wake_on:{.readable} # busy wait, probably 
    447  
    448     my @a is Array::Chan = 1..Inf; 
    449     async { @a.push(1) }; 
    450     async { @a.blocking_shift({ ... }) }; 
    451     async { @a.unshift({ ... }) }; 
    452  
    453  Communication abstractions 
    454  - shared, transactional variables by default 
    455  
    456 # program will wait for _all_ threads 
    457 # unjoined threads will be joined at the beginning of the END block batch 
    458 # of the parent thread that spawned them 
    459460 
    460461 
     
    608609 
    609610  foo(4); # and that's all she wrote 
    610  
    611   # If you don't want your variables to get rebound, use "is copy": 
    612   coro foo ($x is copy) {...} 
    613   # which is sugar for 
    614   coro foo ($x) { 
    615     { 
    616       my $x := $OUTER::x; 
    617       ...; 
    618       # Further calls of &foo rebound $OUTER::x, not $x. 
    619     } 
    620   } 
    621611 
    622612  sub foo {