From 482fe52fc41c23a04bb7f3af8434204da4b629ba Mon Sep 17 00:00:00 2001 From: halw Date: Tue, 1 Mar 2011 23:00:08 +0000 Subject: [PATCH] Author:halw Date:2011-03-01T22:52:38.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@794 abb3cda0-5349-4a8f-a601-0c33ac3a8c38 --- .../concurrent-eiffel-scoop/index.wiki | 4 ++-- .../scoop-examples/barbershop.wiki | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/index.wiki b/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/index.wiki index 72ca07f1..b436bc18 100644 --- a/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/index.wiki +++ b/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/index.wiki @@ -195,12 +195,12 @@ After an asynchronous feature call, the execution of the client proceeds immedia First, every feature call is either a synchronous feature call or an asynchronous feature call. For a particular call, the following rules determine which it is: -A feature call is synchronous in the following cases: +A feature call is '''synchronous''' in the following cases: # It is a non-separate call. # It is a separate call to a query. # It is a feature call which has at least one actual argument which is a separate argument of the enclosing routine. -A feature call is asynchronous in the following case: +A feature call is '''asynchronous''' in the following case: # It is a separate call to a command. Let’s look a little closer at those cases determining synchronous calls. diff --git a/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/scoop-examples/barbershop.wiki b/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/scoop-examples/barbershop.wiki index eeed14a2..6aa5ca1f 100644 --- a/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/scoop-examples/barbershop.wiki +++ b/documentation/current/solutions/concurrent-computing/concurrent-eiffel-scoop/scoop-examples/barbershop.wiki @@ -26,6 +26,23 @@ The SHOP includes features enter and leavedo_hair_cut in class BARBER. This feature is called by a customer when the barber becomes available to cut the customer's hair. do_hair_cut is a function that returns a BOOLEAN. If you look at the source code for do_hair_cut, you'll see that the routine cannot complete with any result other than True ... and this may seem odd. + + + do_hair_cut (an_id: INTEGER): BOOLEAN + -- Called from a customer who wants to get hair cut + require + an_id >= 0 + do + (create {EXECUTION_ENVIRONMENT}).sleep (hair_cut_time * 1000000) + result := true + end + + +Couldn't a function that always returns the exact same predictable result be safely made a procedure? Certainly it could. However, there is a SCOOP oriented reason for this routine being a function rather than a procedure. + +{BARBER}.do_hair_cut is a function in order to become synchronous. Remember that a [[Concurrent Eiffel with SCOOP#Separate types and separate calls|separate call]] which is a query is always a [[Concurrent Eiffel with SCOOP#Synchronous and asynchronous feature calls|synchronous call. In the case of the customer, he needs to leave the shop only after his haircut is complete. Therefore, the query do_hair_cut will be synchronous and ensure that the haircut is complete before the customer leaves the shop. +