| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | ! Copyright (C) 2007 Chris Double. | 
					
						
							|  |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							| 
									
										
										
										
											2014-05-23 23:20:15 -04:00
										 |  |  | USING: help.syntax help.markup kernel ;
 | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | IN: channels | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: <channel> | 
					
						
							| 
									
										
										
										
											2014-05-23 23:20:15 -04:00
										 |  |  | { $values { "channel" channel } | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | } | 
					
						
							|  |  |  | { $description "Create a channel that can be used for communicating between " | 
					
						
							|  |  |  | "concurrent processes and threads. " { $link to } " and " { $link from } | 
					
						
							|  |  |  | " can be used to send and receive data to/from the channel respectively. " | 
					
						
							|  |  |  | "There can be multiple readers and writers on a channel. If there are " | 
					
						
							|  |  |  | "multiple readers or writers, only one is selected at random to resume." | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | { $see-also from to } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: to | 
					
						
							| 
									
										
										
										
											2014-05-23 23:20:15 -04:00
										 |  |  | { $values { "value" object } | 
					
						
							|  |  |  |           { "channel" channel } | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | } | 
					
						
							|  |  |  | { $description "Sends an object to a channel. The send operation is synchronous." | 
					
						
							|  |  |  | " It will block the calling thread until there is a receiver waiting " | 
					
						
							|  |  |  | "for data on the channel. It will return when the receiver has received " | 
					
						
							| 
									
										
										
										
											2014-05-23 23:20:15 -04:00
										 |  |  | "the data successfully." | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | } | 
					
						
							|  |  |  | { $see-also <channel> from } ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | HELP: from | 
					
						
							| 
									
										
										
										
											2014-05-23 23:20:15 -04:00
										 |  |  | { $values  { "channel" channel } | 
					
						
							|  |  |  |            { "value" object } | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | } | 
					
						
							|  |  |  | { $description "Receives an object from a channel. The operation is synchronous." | 
					
						
							| 
									
										
										
										
											2015-07-02 13:31:22 -04:00
										 |  |  | " It will block the calling thread until there is data in the channel." | 
					
						
							| 
									
										
										
										
											2007-09-20 18:09:08 -04:00
										 |  |  | } | 
					
						
							|  |  |  | { $see-also <channel> to } ;
 | 
					
						
							| 
									
										
										
										
											2008-09-14 23:28:54 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ARTICLE: "channels" "Channels" | 
					
						
							|  |  |  | "The " { $vocab-link "channels" } " vocabulary provides a simple abstraction to send and receive objects." $nl | 
					
						
							|  |  |  | "Opening a channel:" | 
					
						
							| 
									
										
										
										
											2009-10-01 15:56:36 -04:00
										 |  |  | { $subsections <channel> } | 
					
						
							| 
									
										
										
										
											2008-09-14 23:28:54 -04:00
										 |  |  | "Sending a message:" | 
					
						
							| 
									
										
										
										
											2009-10-01 15:56:36 -04:00
										 |  |  | { $subsections to } | 
					
						
							| 
									
										
										
										
											2008-09-14 23:28:54 -04:00
										 |  |  | "Receiving a message:" | 
					
						
							| 
									
										
										
										
											2009-10-01 15:56:36 -04:00
										 |  |  | { $subsections from } ;
 | 
					
						
							| 
									
										
										
										
											2008-09-14 23:28:54 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ABOUT: "channels" |