Created
July 30, 2011 20:39
-
-
Save mostlygeek/1115965 to your computer and use it in GitHub Desktop.
Programming Erlang 8.11 Problem #1
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
%% Write a function start(AnAtom, Fun) to register | |
%% AnAtom as spawn(Fun). Make sure your program | |
%% works correctly in the case when two parallel | |
%% processes simultaneously evaluate start/2. In | |
%% this case, you must guarantee that one of | |
%% these processes succeeds and the other fails. | |
-module(ch8prob1). | |
-export([start/2]). | |
start(AnAtom, Fun) -> | |
try register(AnAtom, spawn(Fun)) of | |
true -> true | |
catch | |
error:X -> {error, X} | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is my solution for Programming Erlang Chapter 8, problem #1. It assumes that register/2 is guaranteed atomic within the system.