Created
November 28, 2017 16:41
-
-
Save ishankhare07/f3763411ddd56eea87b1d15be72fef7c to your computer and use it in GitHub Desktop.
a timer in erlang
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
-module(timer). | |
-export([start/2, cancle/1]). | |
start(Time, Fun) -> | |
spawn(fun() -> timer(Time, Fun) end)). | |
cancle(Pid) -> Pid ! cancle. | |
timer(Time, Fun) -> | |
receive | |
cancle -> | |
void | |
after Time -> | |
Fun() | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
call as