Created
September 12, 2010 12:05
-
-
Save shino/576026 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
-module(overload_handler_sample). | |
-auther(shino.shun@gmail.com). | |
-compile(export_all). | |
%% -record(rec, {k, v1, v2, v3}). | |
main() -> | |
%% Mnesia 開始前には subscribe してもアラートは受け取れない | |
subscribe_to_mnesia(before_mnesia_start), | |
mnesia:start(), | |
%% Mnesia 停止すると、以前のサブスクライバは、アラートを受け取れない | |
subscribe_to_mnesia(after_mnesia_start), | |
mnesia:stop(), | |
timer:sleep(500), | |
mnesia:start(), | |
subscribe_to_mnesia(after_mnesia_restart), | |
%% 複数のサブスクライバも可能 | |
subscribe_to_mnesia(after_mnesia_restart2), | |
mnesia:stop(). | |
subscribe_to_mnesia(Tag) -> | |
spawn_link(fun() -> consume_messages(Tag) end). | |
consume_messages(Tag) -> | |
mnesia:subscribe(system), | |
receive | |
Alert -> | |
io:format("[‾p] ‾p‾n", [Tag, Alert]) | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment