aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/gen_fsm.erl
AgeCommit message (Collapse)Author
2012-03-30Update copyright yearsBjörn-Egil Dahlberg
2012-02-24Merge branch 'uw/extending_gen' into maintGustav Simonsson
* uw/extending_gen: Add plugin support for alternative name lookup OTP-9945
2012-01-03Correct spelling of "registered" in various places in the source codeRichard Carlsson
2011-11-24Add plugin support for alternative name lookupUlf Wiger
OTP behaviour instances (gen_server, gen_fsm, gen_event) can currently register themselves either locally or globally, and the behaviour libraries (including gen.erl) support both addressing methods, as well as the normal Pid and {Name, Node}. However, there are alternative registry implementations - e.g. gproc - and one can well imagine other ways of locating a behaviour instance, e.g. on a node connected only via a TCP tunnel, rather than via Distributed Erlang. In all these cases, one needs to write extra code to identify the behaviour instance, even though the instance itself need not be aware of how it is located. This patch introduces a new way of locating a behaviour instance: {via, Module, Name}. Module is expected to export a subset of the functions in global.erl, namely: register_name(Name, Pid) -> yes | no whereis_name(Name) -> pid() | undefined unregister_name(Name) -> ok send(Name, Msg) -> Pid Semantics are expected to be the same as for global.erl This can be used in all places where {global, Name} is accepted. faulty export in gen_fsm_SUITE.erl await process death in dummy_via:reset() fix error in gen_[server|fsm]:enter_loop() fix documentation
2011-11-14Remove all use of global:safe_whereis_name/1Hans Bolinder
Calls to global:whereis_name/1 have been substituted for calls to global:safe_whereis_name/1 since the latter is not safe at all. The reason for not doing this earlier is that setting a global lock masked out a bug concerning the restart of supervised children. The bug has now been fixed by a modification of global:whereis_name/1. (Thanks to Ulf Wiger for code contribution.)
2011-11-14Fix a minor race in gen_fsmHans Bolinder
Fixed a minor race conditions in gen_fsm:start*: if one of these functions returned {error,Reason} or ignore, the name could still be registered (either locally or in global. This is the same modification as was done for gen_server in OTP-7669.
2011-10-07Add '-callback' attributes in stdlib's behavioursStavros Aronis
Replace the behaviour_info(callbacks) export in stdlib's behaviours with -callback' attributes for all the callbacks.
2011-08-16emulator: Add a fourth element in exception stacktracesBjörn Gustavsson
This commit is a preparation for introducing location information (filename/line number) in stacktraces in exceptions. Currently a stack trace looks like: [{Mod1,Function1,Arity1}, . . . {ModN,FunctionN,ArityN}] Add a forth element to each tuple that can be used indication the filename and line number of the source file: [{Mod1,Function1,Arity1,Location1}, . . . {ModN,FunctionN,ArityN,LocationN}] In this commit, the fourth element will just be an empty list, and we will change all code that look at or manipulate stacktraces.
2010-07-07Fix format_status bug for unregistered gen_event processesGeoff Cant
Port the gen_fsm code for format_status to gen_event in order to prevent a lists:concat([...,pid()]) crash when calling sys:get_status/1 on an unregistered gen_event process. Refactor format_status header code from gen_* behaviours to module gen. Extend the format_status tests in gen_event_SUITE to cover format_status bugs with anonymous gen_event processes.
2010-05-27handle {global, term()} names in format_status/2Steve Vinoski
The gen_fsm, gen_server, and wx_object format_status implementations fail to handle global names of the form {global, term()} where term() is something other than an atom, pid, or list. Change these format_status implementations to treat names that are atoms, pids, or lists as before, but for all other terms, set the header property of the function return value to a tuple whose first element is a string describing the return value and whose second element is the name term. Add unit tests for gen_server and gen_fsm to verify sys:get_status calls work successfully for globally registered instances.
2010-05-12Extend format_status for gen_server/gen_fsm termination error loggingSteve Vinoski
When a gen_server or gen_fsm process terminates abnormally, sometimes the text representation of the process state can occupy many lines of the error log, depending on the definition of the state term. Developers sometimes would like a way to trim out parts of the state from the log if those parts don't contribute to documenting the circumstances of the error, thereby helping to reduce the amount of logged output. Since the format_status callback can already format and specialize gen_server and gen_fsm state for inclusion in the term returned from sys:get_status, this patch extends format_status in a backward-compatible way to also be able to specialize the state logged for abnormal gen_server and gen_fsm termination, and includes new unit tests to verify the new functionality. This patch also eliminates the previous restriction that the status returned by format_status must be a list. It can now be any term. The documentation is extended to cover the new usage for format_status, and it's been improved to recommend a form for the normal case that allows the returned status to fit well with the rest of the term returned by sys:get_status. The documentation is clear that this form is only recommended, not required.
2010-04-14Merge branch 'ks/stdlib' into devErlang/OTP
* ks/stdlib: erl_parse.yrl: Add missing operator in type declaration stdlib: Add types and specs stdlib: Use fun object instead of {M,F} tuple ets: Cleanup as suggested by tidier OTP-8576 ks/stdlib
2010-04-13stdlib: Use fun object instead of {M,F} tupleKostis Sagonas
2009-11-29gen_fsm: Fix format_status/2 to handle PidsSteve Vinoski
gen_fsm:format_status/2 currently crashes if Name in the process state is a Pid. Handle Name in the same way as in gen_server:format_status/2 to eliminate the crash.
2009-11-20The R13B03 release.OTP_R13B03Erlang/OTP