you’re on your way 4
161
asynchronous applications
Now wait just a second. That’s it? You
completely forgot something—what if
the rst coffee maker is already brewing
coffee? And what about the second coffee
maker? When should we use it?
Each coffee maker can only brew one cup at a time, so what if
the rst coffee maker is already brewing coffee? Somehow we
need to nd out if the rst coffee maker status is “Idle” before
we send a new request. If it’s busy, we can try the second
coffee maker. And if that one’s busy... well, then Jim’s gonna
have to wait a bit for his coffee.
How do you think we can get the status of each coffee maker?
Here’s the HTML for the rst coffee maker... what do you
think we should do?
<div id=”coffeemaker1”>
<h2>Coffee Maker #1</h2>
<p><img src=”images/CoffeeMaker1.gif”
alt=”Coffee Maker #1” /></p>
<div id=”coffeemaker1-status”>Idle</div>
</div>
Which coffee maker should we use?
Remember, the second
coffee maker HTML is
very similar to this.
How do you think we can nd out the status of the coffee
makers? And how can we update the status when one is
brewing coffee, and when the coffee maker nishes brewing?
brain
power
Keep thinking about
this, and we’ll come
back to it a little
later in the chapter.