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

« back to all changes in this revision

Viewing changes to lib/stdlib/src/gen_fsm.erl

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-05-07 15:07:37 UTC
  • mfrom: (1.2.1 upstream) (5.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20090507150737-i4yb5elwinm7r0hc
Tags: 1:13.b-dfsg1-1
* Removed another bunch of non-free RFCs from original tarball
  (closes: #527053).
* Fixed build-dependencies list by adding missing comma. This requires
  libsctp-dev again. Also, added libsctp1 dependency to erlang-base and
  erlang-base-hipe packages because the shared library is loaded via
  dlopen now and cannot be added using dh_slibdeps (closes: #526682).
* Weakened dependency of erlang-webtool on erlang-observer to recommends
  to avoid circular dependencies (closes: #526627).
* Added solaris-i386 to HiPE enabled architectures.
* Made script sources in /usr/lib/erlang/erts-*/bin directory executable,
  which is more convenient if a user wants to create a target Erlang system.
* Shortened extended description line for erlang-dev package to make it
  fit 80x25 terminals.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
%% ``The contents of this file are subject to the Erlang Public License,
 
1
%%
 
2
%% %CopyrightBegin%
 
3
%% 
 
4
%% Copyright Ericsson AB 1996-2009. All Rights Reserved.
 
5
%% 
 
6
%% The contents of this file are subject to the Erlang Public License,
2
7
%% Version 1.1, (the "License"); you may not use this file except in
3
8
%% compliance with the License. You should have received a copy of the
4
9
%% Erlang Public License along with this software. If not, it can be
5
 
%% retrieved via the world wide web at http://www.erlang.org/.
 
10
%% retrieved online at http://www.erlang.org/.
6
11
%% 
7
12
%% Software distributed under the License is distributed on an "AS IS"
8
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9
14
%% the License for the specific language governing rights and limitations
10
15
%% under the License.
11
16
%% 
12
 
%% The Initial Developer of the Original Code is Ericsson Utvecklings AB.
13
 
%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings
14
 
%% AB. All Rights Reserved.''
15
 
%% 
16
 
%%     $Id$
 
17
%% %CopyrightEnd%
17
18
%%
18
19
-module(gen_fsm).
19
20
 
121
122
         system_code_change/4,
122
123
         format_status/2]).
123
124
 
124
 
-import(error_logger , [format/2]).
 
125
-import(error_logger, [format/2]).
125
126
 
126
127
%%% ---------------------------------------------------
127
128
%%% Interface functions.
128
129
%%% ---------------------------------------------------
129
130
 
 
131
-spec behaviour_info(atom()) -> 'undefined' | [{atom(), arity()}].
 
132
 
130
133
behaviour_info(callbacks) ->
131
134
    [{init,1},{handle_event,3},{handle_sync_event,4},{handle_info,3},
132
135
     {terminate,3},{code_change,4}];
311
314
%%% ---------------------------------------------------
312
315
init_it(Starter, self, Name, Mod, Args, Options) ->
313
316
    init_it(Starter, self(), Name, Mod, Args, Options);
314
 
init_it(Starter, Parent, Name, Mod, Args, Options) ->
 
317
init_it(Starter, Parent, Name0, Mod, Args, Options) ->
 
318
    Name = name(Name0),
315
319
    Debug = gen:debug_options(Options),
316
320
    case catch Mod:init(Args) of
317
321
        {ok, StateName, StateData} ->
335
339
            exit(Error)
336
340
    end.
337
341
 
 
342
name({local,Name}) -> Name;
 
343
name({global,Name}) -> Name;
 
344
name(Pid) when is_pid(Pid) -> Pid.
 
345
 
338
346
%%-----------------------------------------------------------------
339
347
%% The MAIN loop
340
348
%%-----------------------------------------------------------------
380
388
system_continue(Parent, Debug, [Name, StateName, StateData, Mod, Time]) ->
381
389
    loop(Parent, Name, StateName, StateData, Mod, Time, Debug).
382
390
 
383
 
-spec(system_terminate/4 :: (_, _, _, [any(),...]) -> no_return()).
 
391
-spec system_terminate(term(), _, _, [term(),...]) -> no_return().
384
392
 
385
393
system_terminate(Reason, _Parent, Debug,
386
394
                 [Name, StateName, StateData, Mod, _Time]) ->
518
526
%%% Terminate the server.
519
527
%%% ---------------------------------------------------
520
528
 
521
 
-spec(terminate/7 :: (_, _, _, atom(), _, _, _) -> no_return()).
 
529
-spec terminate(term(), _, _, atom(), _, _, _) -> no_return().
522
530
 
523
531
terminate(Reason, Name, Msg, Mod, StateName, StateData, Debug) ->
524
532
    case catch Mod:terminate(Reason, StateName, StateData) of
531
539
                    exit(normal);
532
540
                shutdown ->
533
541
                    exit(shutdown);
 
542
                {shutdown,_}=Shutdown ->
 
543
                    exit(Shutdown);
534
544
                _ ->
535
545
                    error_info(Reason, Name, Msg, StateName, StateData, Debug),
536
546
                    exit(Reason)