ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/Channel.pm
(Generate patch)

Comparing Coro/Coro/Channel.pm (file contents):
Revision 1.117 by root, Mon Oct 8 23:16:15 2012 UTC vs.
Revision 1.118 by root, Sun Dec 2 16:18:30 2012 UTC

87 87
88=item $q->shutdown 88=item $q->shutdown
89 89
90Shuts down the Channel by pushing a virtual end marker onto it: This 90Shuts down the Channel by pushing a virtual end marker onto it: This
91changes the behaviour of the Channel when it becomes or is empty to return 91changes the behaviour of the Channel when it becomes or is empty to return
92C<undef>, almost as if infinitely many C<undef> elements have been put 92C<undef>, almost as if infinitely many C<undef> elements had been put
93into the queue. 93into the queue.
94 94
95Specifically, this function wakes up any pending C<get> calls and lets 95Specifically, this function wakes up any pending C<get> calls and lets
96them return C<undef>, the same on future C<get> calls. C<size> will return 96them return C<undef>, the same on future C<get> calls. C<size> will return
97the real number of stored elements, though. 97the real number of stored elements, though.
104This method is useful to signal the end of data to any consumers, quite 104This method is useful to signal the end of data to any consumers, quite
105similar to an end of stream on e.g. a tcp socket: You have one or more 105similar to an end of stream on e.g. a tcp socket: You have one or more
106producers that C<put> data into the Channel and one or more consumers who 106producers that C<put> data into the Channel and one or more consumers who
107C<get> them. When all producers have finished producing data, a call to 107C<get> them. When all producers have finished producing data, a call to
108C<shutdown> signals this fact to any consumers. 108C<shutdown> signals this fact to any consumers.
109
110A common implementation uses one or more threads that C<get> from
111a channel until it returns C<undef>. To clean everything up, first
112C<shutdown> the channel, then C<join> the threads.
109 113
110=cut 114=cut
111 115
112sub shutdown { 116sub shutdown {
113 Coro::Semaphore::adjust $_[0][SGET], 1_000_000_000; 117 Coro::Semaphore::adjust $_[0][SGET], 1_000_000_000;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines