From e411dad72c34be0000aa6c8be431a0d3c611d600 Mon Sep 17 00:00:00 2001 From: halw Date: Mon, 28 Feb 2011 21:53:47 +0000 Subject: [PATCH] Author:halw Date:2011-02-28T21:53:47.000000Z git-svn-id: https://svn.eiffel.com/eiffel-org/trunk@793 abb3cda0-5349-4a8f-a601-0c33ac3a8c38 --- .../scoop-examples/barbershop.wiki | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 93c4e215..eeed14a2 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 @@ -13,8 +13,19 @@ The [http://en.wikipedia.org/wiki/Sleeping_barber_problem barbershop], sometimes Also involved are a number of shaggy-haired customers. A customer entering the barbershop looks around and assesses the situation. If all the waiting room chairs are occupied, the customer leaves the shop to return again at a time when hopefully the queue will be shorter. If there is an open chair the customer sits down and waits for the barber. -Once the barber has finished cutting a customer's hair, the customer leaves the shop which allows another customer to enter the shop and the the next customer in the queue to get a haircut. +Once the barber has finished cutting a customer's hair, the customer leaves the shop which allows another customer to enter the shop (if all the chairs had been occupied) and the the next customer (if there is one) in the queue to get a haircut. + +In this example, even after getting their hair cut, the customers come back to the shop until they have had their hair cut some prescribed number of times. =Highlights= +The example contains classes that model the barber (BARBER), the customers (CUSTOMER), and the shop with its waiting area (SHOP). The root class creates as separate objects the barber, the shop, and the set of customers. As each customer is created, it is launched on its lifecycle of getting haircut after haircut until haircuts are no longer needed. + +The SHOP includes features enter and leave. Customers call the enter feature to find out if there is a chair available in the shop. Customers call leave, after their hair has been cut. Both of these calls are "wrapped" as separate calls in the class CUSTOMER. + +A typical customer lives in this way: As long as he still needs haircuts, he repeatedly does the following steps: He tries to enter the shop. If he's unsuccessful because all the chairs are occupied, he goes off for a while (in the implementation, his processor sleeps and then comes to the end of this step). If he is able to enter the shop, then he puts himself in the queue for a haircut. Once his haircut is complete, he reduces his number of haircuts needed by one, and leaves the shop. + + + +