This file contains hidden or 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
%Authors: Emma Ireland and John McCall | |
%Note: For some reason you can't pass a table id to processes, it just doesn't work so we have to create a Table to give it, | |
%then send it a message to create a new table in its process. | |
%Note: When calling createProcesses the ListOfHosts needs to have at least 2 arguments (even just [node(), node()]), because | |
%crypto:rand_uniform(1, length(ListOfHosts)) will return 2 if length of hosts is 1 (really it should throw a badarg exception, but doesn't). | |
%Note: To see the table at the end, find our aggregator using global:whereis_name and then send it showTable as a message. | |
This file contains hidden or 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
%Authors: Emma Ireland and John McCall | |
-module(dist_bakery). | |
-export([server/0, bake/2, customer/0, manager/2, pair/2, create_people/4, fib/1]). | |
server() -> | |
receive | |
{serveCustomer, CustomerID, ToBake} -> | |
io:format("Server: ~w is serving customer: ~w~n", [self(), CustomerID]), | |
bake(CustomerID, ToBake), | |
server() |
This file contains hidden or 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
% Authors: Emma Ireland and John McCall | |
-module(bakery). | |
-export([server/0, customer/0, manager/2, pair/2, create_people/2, fib/1]). | |
server() -> | |
receive | |
{serveCustomer, CustomerID} -> | |
io:format("Server: ~w is serving customer: ~w~n", [self(), CustomerID]), | |
ToBake = crypto:rand_uniform(30, 40), | |
self() ! {bake, CustomerID, ToBake}, |