Jump to content

Synchronous concurrency: Difference between revisions

m
m (→‎{{header|TXR}}: Fix lang tag.)
Line 1,519:
When the file has been read and sent to channel chPrint, this channel is closed. All tasks waiting for an object in this channel are released and receive null. Then printing task returns number of printed lines into chCount channel for the main task.
 
<lang Oforth>funcimport: printing(chPrint, chCount)parallel
{
0 while(chPrint receive dup notNull) [ println 1 + ] drop
chCount send drop
}
 
: printing(chPrint, chCount)
func: concurrentPrint(aFileName)
0 while( chPrint receive dup notNull ) [ println 1 + ] drop
{
chCount send drop ;
 
func: concurrentPrint(aFileName)
| chPrint chCount line |
Channel new ->chPrint
Line 1,533 ⟶ 1,532:
#[ printing(chPrint, chCount) ] &
 
File newMode(aFileName, File.UTF8) new forEach: line [ chPrint send(line) drop ]
chPrint close
chCount receive "Number of lines printed : " print println ;</lang>
}</lang>
 
=={{header|ooRexx}}==
1,015

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.