Last active
December 20, 2015 14:19
-
-
Save kachayev/6145771 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main() -> | |
Clients = ch:make(), | |
spawn(clients_generator, [Clients]), | |
lists:foreach(fun(_) -> | |
spawn(barber, [Clients]) | |
end, lists:seq(1,10)). | |
clients_generator(Clients) -> | |
ch:enqueue(client, Clients), | |
timer:sleep(random:uniform(100)), | |
clients_generator(Clients). | |
barber(Clients) -> | |
ch:foreach(fun(_) -> | |
timer:sleep(100) | |
end, Clients). | |
%% buffer for waiting room? | |
Clients = ch:buffer(?MAX_WAITERS, ch:make()) | |
%% max clients restrictions for each barber? | |
ch:foreach(fun(_) -> timer:sleep(100) end, | |
ch:take(?MAX_CLIENTS, Clients)). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment