aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/gen_event.erl
AgeCommit message (Collapse)Author
2018-01-22stdlib: Correct contractsHans Bolinder
2017-09-05stdlib : Improve handling of UnicodeHans Bolinder
2017-05-15Merge pull request #1407 from eltex-ecss/auto_hibernate_timeoutIngela Andin
Add option hibernate_after to gen_server, gen_statem and gen_event. Also added to the deprecated gen_fsm behaviour. OTP14405
2017-05-04Update copyright yearRaimo Niskanen
2017-05-02"auto_hibernate_timeout" option renamed to "hibernate_after".Anton N Ryabkov
It was done because "hibernate_after" option already used in ssl for the same reason.
2017-05-02Added reuse of code.Anton N Ryabkov
2017-05-02Added support of auto_hibernate_timeout option for gen_server, gen_fsm, ↵Anton N Ryabkov
gen_event process's. There is realized gen_server, gen_fsm, gen_event automatic hibernation functionality. Added unit tests for realized functionality. Added documentation for auto_hibernate_timeout option.
2017-04-21stdlib: Make gen_event callbacks optionalZandra Norman
2017-03-02Merge branch 'maint'Hans Bolinder
* maint: typer: Update runtime dependencies dialyzer: Update runtime dependencies Correct documentation of get_modules message
2017-03-01Correct documentation of get_modules messageSiri Hansen
2016-12-16stdlib: Add start options to gen_eventBjörn-Egil Dahlberg
* New gen_event:start/2 and gen_event:start_link/2 * Extend gen_event:start/1 and gen_event:start_link/1 to handle an option list as input. The options to gen_event are the same as to gen_server.
2016-12-16stdlib: Remove whitespace errors in gen_eventBjörn-Egil Dahlberg
2016-04-25Merge branch 'raimo/new-gen-state-machine/OTP-13065'Raimo Niskanen
* raimo/new-gen-state-machine/OTP-13065: (52 commits) Add section on state filtering Promote gen_statem over gen_fsm Modify code_change/4 to return CallbackMode Use ?NAME macro in examples Introduce Fred Herbert suggested additions Introduce corrections from Fred Hebert and Ingela Use .png pictures instead of .gif Write Design Principles chapter Fix missing short forms for event timeout Do more intricate Fred Hebert doc changes Change Caller -> From as suggested by Fred Hebert Do documentation improvements from Fred Hebert Fix broken documenation reference Rename state_timeout -> event_timeout Fix most of the system docs and emacs mode Change code_change/4 to {ok,State,Data} Fixup sharpened test suite Sharpen test suite Remove the remove_event action and all alike Relax caller() type check and cleanup ... Conflicts: lib/stdlib/src/gen.erl lib/stdlib/src/gen_event.erl lib/stdlib/src/gen_fsm.erl lib/stdlib/src/gen_server.erl lib/stdlib/test/error_logger_forwarder.erl
2016-03-15update copyright-yearHenrik Nord
2015-12-15Factor out common code to gen.erlRaimo Niskanen
2015-06-18Change license text to APLv2Bruce Yinhe
2014-10-01Merge branch 'maint'Siri Hansen
2014-09-30Fix dialyzer warnings for unmatched return in gen_eventSiri Hansen
This was introduced by PR 445, commit 2e78c5f3e7f9991484ceb5d56e5b0086331101be.
2014-09-25Merge branch 'maint'Marcus Arendt
Conflicts: lib/stdlib/src/gen_event.erl
2014-09-11Do not rely on macros with implicit varsJosé Valim
This commit also provides the benefit that the Label argument in gen:call/3 is no longer used, as we can access the sender in the From argument. Therefore, we should be able to change the Label to something more relevant in the future.
2014-05-26Update gen_event:stop to be synchronousSiri Hansen
This function now uses proc_lib:stop, which guarantees that the process is terminated before the function return.
2014-04-28Introduce the attribute -optional_callbacks in the context of behavioursHans Bolinder
2014-03-21fix sys:get_state/1,2 and sys:replace_state/2,3 when sys suspendedSteve Vinoski
Add two new system callbacks Module:system_get_state/1 and Module:system_replace_state/2 to allow sys:get_state/1,2 and sys:replace_state/2,3 to operate correctly even if a process is sys suspended. Modify gen_server, gen_fsm, and gen_event to support the new callbacks. If a callback module does not export these functions, then by default the Misc value (the same as that passed as the final argument to sys:handle_system_msg/6, and returned as part of the return value of sys:get_status/1,2) is treated as the callback module's state. The previous behaviour of intercepting the system message and passing a tuple of size 2 as the last argument to sys:handle_system_msg/6 is no longer supported. Add tests to verify the correctness of sys:get_state/1,2 and sys:replace_state/2,3 when processes are sys suspended. Add two tests for modules that implement special processes, one that exports system_get_state/1 and system_replace_state/2 and one that doesn't. Much of the credit for this patch goes to James Fish, who reported the initial problem and implemented much of the fix.
2013-06-12Update copyright yearsBjörn-Egil Dahlberg
2013-04-02add sys:get_state/1,2 and sys:replace_state/2,3Steve Vinoski
At Erlang Factory 2013 there was discussion during one of the talks about the sys:get_status functions and how useful they were for debugging. Geoff Cant mentioned it would be very useful if the sys module also provided functions to use while debugging to get just the state of a process and also to be able to replace the state of a process, and many others in the audience appeared to agree. The sys:get_state/1,2 functions return the state of a gen_server, gen_fsm, or gen_event process. The return value varies depending on the process type: process state for a gen_server, state name and state data for a gen_fsm, and handler module, handler id, and handler state for each handler registered in a gen_event process. The sys:replace_state/2,3 functions allow the state of a gen_server, gen_fsm, or gen_event process to be replaced with a new state. These functions take a function argument that updates or replaces the process state; using a function to change the state eliminates the race condition of first reading the state via sys:get_state/1 or sys:get_state/2, using its return value to create a new state, and then replacing the old state with the new state, since during that time the process might have received other calls or messages that could have changed its state. * For a gen_server process, the state replacement function takes the process state as an argument and returns a new state. * For a gen_fsm process, the state replacement function gets a tuple of {StateName, StateData} and returns a similar tuple that specifies a new state name, new state data, or both. * For a gen_event process, the state replacement function is called for each registered event handler. It gets a tuple {Module, Id, HandlerState} and returns a similar tuple that specifies the same Module and Id values but may specify a different value for HandlerState. If the state replacement function crashes or results in an error, the original state of a gen_server or gen_fsm process is maintained; if such a crash occurs for a gen_event process, the original state of the event handler for which the state replacement function was called is maintained, but the states of other event handlers of the same gen_event process may still be updated if no errors or crashes occur while replacing their states. Add documentation for sys:get_state/1,2 and sys:replace_state/2,3. The documentation explicitly notes that the functions are intended for use during debugging. Add new tests for these functions to gen_server_SUITE, gen_fsm_SUITE, and gen_event_SUITE.
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
2011-11-30Fix dialyzer warning about gen_event callback init/1 in log_mf_hSiri Hansen
The warning is about log_mf_h having a different spec for gen_event callback init/1 than defined in gen_event.erl. log_mf_h allows return value {error,Reason}, while gen_even only specifies successful return values. This commit add {error,Reason} as a valid return value to the gen_event callback, since this is handled by the code.
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-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.
2011-05-12Types and specifications have been modified and addedHans Bolinder
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-12Add support for the format_status callback to gen_eventSteve Vinoski
The gen_server and gen_fsm behaviors support the format_status callback to allow developers to specialize how callback module state appears within the return value of sys:get_status and within logged output resulting from abnormal process termination. This patch adds similar support to gen_event. Event handlers that export a format_status/2 function, which is an optional callback, and are registered with an event manager will now have their format_status callbacks invoked when sys:get_status is called on the event manager. The term returned from format_status for this case replaces the default handler state in the sys:get_status return value. This patch also extends gen_event to call an event handler's format_status function (if it exports one) should the handler terminate abnormally. The term returned from format_status is logged in place of the handler's state. This is intended to allow developers to control how much output is logged in the case of abnormal termination. The documentation is appropriately extended and new unit tests are added to cover the new gen_event format_status functionality.
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-20The R13B03 release.OTP_R13B03Erlang/OTP