gen_fsm stands for "generic finite state machine", a module behaviour in Erlang.
Questions tagged [gen-fsm]
24 questions
10
votes
1 answer
when to use Gen_Fsm and when to use Gen_Server?
After checking out Gen_Fsm and Gen_Server documents, I found that, more or less, they act as similar behavior. In my opinion, if there is one loop function for sending broadcast or listening tcp sock, it is better to use Gen_Fsm, or else to use…

why
- 23,923
- 29
- 97
- 142
9
votes
3 answers
How to visualize an Erlang gen_fsm
Do you know of any existing tool to graphically render the diagram of an Erlang gen_fsm starting from the source code?

Roberto Aloi
- 30,570
- 21
- 75
- 112
6
votes
2 answers
Erlang: Implementing a Finite State Machine using gen_fsm
I'm looking for an example of a simple FSM implemented in Erlang using the gen_fsm from OTP.

Finite State Machine
- 69
- 1
- 2
5
votes
1 answer
Allowing a gen_fsm to timeout if it receives no messages
Normally if I'd like to have an Erlang process timeout I would use the following construct:
receive
Msg -> ok; %% handle message
after 60000 ->
%% Handle timeout and exit
end.
Is there a similar mechanism in the OTP servers such as…

Jeff Thompson
- 2,662
- 2
- 18
- 17
2
votes
1 answer
Terminate gen_fsm if no event come
I want my FSM to terminate any time event doesn't come after specified amout of time in every state.
I can achieve such a scenario only in case there is no event after FSM creation by specifing timeout value in init callback, but I would like to…

mkorszun
- 4,461
- 6
- 28
- 43
2
votes
1 answer
Converting Learn You Some Erlang tutorial from gen_fsm to gen_statem
I have been going through the chapter Rage Against The Finite State Machine of the tutorial, and it uses gen_fsm, which has been deprecated in favor of gen_statem. When running the tests I always get stuck because one of the clients are on the…

sicro
- 39
- 3
2
votes
4 answers
how to handle termination of gen_fsm
I have a MAIN process that spawn an implementation of a gen_fsm behavior, but this MAIN process is not an implementation of supervisor behavior, its just another module.
Let say the implementation of gen_fsm is called GAME_ROOM.
My case is like…

Bromo Programmer
- 670
- 2
- 13
- 37
2
votes
3 answers
Unique atom for gen_fsm:start/3 in Erlang
I'm currently in a project making a gameserver. Every player is supposed have an own process with gen_fsm behavior. To start gen_fsm with start/3 we need a unique atom, currently we use make_ref() and have found a way to make this ref into an atom…

softarn
- 5,327
- 3
- 40
- 54
2
votes
1 answer
How can I know when it's the last cycle of my process restarted by the supervisor in erlang
I have a simple_one_for_one supervisor which has gen_fsm children.
I want each gen_fsm child to send a message only on the last time it terminates.
Is there any way to know when is the last cycle?
here's my…

dina
- 4,039
- 6
- 39
- 67
2
votes
1 answer
Pass control from one gen_fsm to another
I'm creating a generic Erlang server that should be able to handle hundreds of client connections concurrently. For simplicity, let's suppose that the server performs for every client some basic computation, e.g., addition or subtraction of every…

adizere
- 224
- 1
- 10
1
vote
1 answer
eunit test for timeout
How can I test that a gen_fsm does indeed timeout with eunit?
{ok, GH} = gen_fsm:start_link(myFSM, [], []),
//after 15 sec it should timeout if no messages received.
//What must I write here to test it?

Daniel
- 20,420
- 10
- 92
- 149
1
vote
1 answer
how to transfer gen_server/gen_fsm from node to node
I would like to know what is the suggested way (if any) to move a gen_server/gen_fsm from erlang node A to erlang node B preserving its internal state.

user601836
- 3,215
- 4
- 38
- 48
1
vote
1 answer
gen_fsm erlang timeout
I have a question on gen_fsm timeout. Let's say you have a set of gen_fsm with two states (in future can be more): idle which is the starting state and working.
Any 5 seconds the gen_fsm will check a particular parameter and according to it will…

user601836
- 3,215
- 4
- 38
- 48
1
vote
1 answer
How to use Boost.MSM is_flag_active inside on_entry?
I would like to use is_flag_active() function inside one of my state's on_entry template function:
struct StBladeDown : public msm::front::state<> {
template
void on_entry(Event const& event, FSM& fsm) {
…

Gabor Marton
- 2,039
- 2
- 22
- 33
1
vote
1 answer
Using more than one erlang behaviour
I have an erlang gen_fsm process that talks to a remote server via tcp using erlang's built-in gen_tcp.
I would like to make this a web-socket client. Upon some investigation, I got this erlang websocket client library Erlang Websocket client.…

sad
- 820
- 1
- 9
- 16