Copyright © 2023, Fred Youhanaie
Behaviours: gen_server.
Authors: Fred Youhanaie (fyrlang@anydata.co.uk).
This is the main admin manager for espace
instances. It is the
custodian of the two ETS tables and replaces the table admin side
of the espace_tspace_srv
and espace_tspatt_srv
servers.
There will be one such server for each instance of espace
. The
server communicates with the etsmgr
server and handles the setup
and teardown of the ETS tables during the startup and shutdown
phases.
espace
. The tables are created with public access mode so that
individual processes can perform their own input/output
operations, see the espace_cli
module for details.
ets_init/2* | Create a single ETS table via etsmgr. |
ets_recover/2* | Recover from etsmgr crash. |
handle_call/3 | Handling call messages. |
handle_cast/2 | Handling cast messages. |
handle_continue/2 | Handling continue requests. |
handle_info/2 | Handling all non call/cast messages. |
handle_wait4etsmgr/2* | wait for etsmgr to (re)start, ensure it manages our ETS
tables, and update the State data. |
init/1 | Initializes the server. |
start_link/1 | Starts the server. |
terminate/2 | This function is called by a gen_server when it is about to terminate. |
wait_for_ets/1 | Allows the client(s) to wait for the tables to be ready. |
ets_init(Inst_name::atom(), Table::tspace | tspatt) -> {ok, pid(), ets:tid()} | {error, term()}
Create a single ETS table via etsmgr.
ets_recover(Inst_name::atom(), Table::tspace | tspatt) -> {ok, pid(), ets:tid()} | {error, term()}
Recover from etsmgr crash.
handle_call(Request::term(), From::{pid(), term()}, State::term()) -> {reply, Reply::term(), NewState::term()}
Handling call messages
handle_cast(Request::term(), State::term()) -> {noreply, NewState::term()}
Handling cast messages
handle_continue(Request::term(), State::term()) -> {noreply, term(), hibernate} | {noreply, term(), timeout()} | {noreply, term(), {continue, term()}} | {noreply, term()} | {stop, term(), term()}
Handling continue requests.
We use{continue, init}
from espace_mgr:init/1
to ensure
that etsmgr
is started and is managing our ETS tables before
handling the first request.
handle_info(Info::timeout() | term(), State::term()) -> {noreply, term()} | {stop, normal | term(), term()}
Handling all non call/cast messages
We can expect an EXIT
message if the etsmgr
server exits
unexpectedly. In this case we need to wait for the new etsmgr
server to restart and be told of our ETS table before continuing
further.
ETS-TRANSFER
messages whenever we are handed
over the ETS table.
handle_wait4etsmgr(X1::init | recover, State::term()) -> {ok, term()} | {error, term()}
wait for etsmgr to (re)start, ensure it manages our ETS
tables, and update the State
data.
init(Inst_name::atom()) -> {ok, term(), {continue, init}}
Initializes the server
start_link(Inst_name::atom()) -> {ok, pid()} | ignore | {error, {already_started, pid()} | term()}
Starts the server.
We expect an instance name to be supplied, which will be used to uniquely identify the ETS tables for the instance.terminate(Reason::term(), State::term()) -> ok
This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored.
wait_for_ets(Inst_name::atom()) -> true
Allows the client(s) to wait for the tables to be ready.
This call will not be serviced until the table have been created via{continue,init}
.
Generated by EDoc