#
#   Restaurant model - version 1
#

from cofunctions import *
from simulation import start, hold, now, run

import random
random.seed(12345)

@cofunction
def generate_customers(cocall, howmany):
	for i in range(howmany):
		print("Generating a customer at", now())
		start(customer, i)
		yield cocall(hold, random.expovariate(1/5))

@cofunction
def customer(cocall, i):
	print("Customer", i, "starting to eat spam")
	yield cocall(hold, random.normalvariate(10, 5))
	print("Customer", i, "finished eating at", now())

start(generate_customers, 5)
run()