~ubuntu-branches/debian/squeeze/erlang/squeeze

« back to all changes in this revision

Viewing changes to lib/sasl/doc/src/rel/gs1.2.erl

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-02-15 16:42:52 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20090215164252-dxpjjuq108nz4noa
Tags: 1:12.b.5-dfsg-2
Upload to unstable after lenny is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
-module(gs1).
 
2
-vsn(2).
 
3
-behaviour(gen_server).
 
4
 
 
5
-export([get_data/0, get_time/0]).
 
6
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, 
 
7
         terminate/2, code_change/3]).
 
8
 
 
9
-record(state, {data, time}).
 
10
 
 
11
get_data() -> 
 
12
    gen_server:call(gs1, get_data).
 
13
 
 
14
get_time() -> 
 
15
    gen_server:call(gs1, get_time).
 
16
 
 
17
init([Data]) ->
 
18
    {ok, #state{data = Data, time = erlang:time()}}.
 
19
 
 
20
handle_call(get_data, _From, State) ->
 
21
    {reply, {ok, State#state.data}, State};
 
22
handle_call(get_time, _From, State) ->
 
23
    {reply, {ok, State#state.time}, State}.
 
24
 
 
25
handle_cast(_Request, State) ->
 
26
    {noreply, State}.
 
27
 
 
28
handle_info(_Info, State) ->
 
29
    {noreply, State}.
 
30
 
 
31
terminate(_Reason, _State) ->
 
32
    ok.
 
33
 
 
34
code_change(1, {state, Data}, _Extra) ->
 
35
    {ok, #state{data = Data, time = erlang:time()}}.