Erlang gen_server template




















Find centralized, trusted content and collaborate around the technologies you use most. Connect and share knowledge within a single location that is structured and easy to search.

The code is working as intended, but I don't want the logger to print it out as its a graceful termination. From the manual :. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. To prevent late answers after the time-out from polluting the message queue of the caller, a middleman process is used to do the calls.

Late answers are then discarded when they arrive to a terminated process. Timeout is an integer greater then or equal to zero that specifies how many milliseconds to wait for an reply, or the atom infinity to wait indefinitely. If no reply is received within the specified time, the function returns timeout. Assuming that the server executes on a node supporting aliases introduced in OTP 24 no response will be received after a timeout.

Otherwise, a garbage response might be received at a later time. Client must be the From argument provided to the callback function. This function is to be called, directly or indirectly, by the supervisor. Using spawn option monitor is not allowed, it causes the function to fail with reason badarg. If the start is not successful, the caller will be blocked until the DOWN message has been received and removed from the message queue. Orders a generic server to exit with the specified Reason and waits for it to terminate.

The function returns ok if the server terminates with the expected reason. An exit signal with the same reason is sent to linked processes and ports. Commercial support is available through Nine Nines. Prev Next. Chapter 2. Getting started. Creating a folder for your project. Downloading Erlang. Bash completion. Getting started with OTP applications. Getting started with OTP libraries. Getting started with OTP releases. Getting started from scratch. Using spaces instead of tabs. Using templates.

Hiding Erlang. Getting help. If it is not specified, it defaults to false. An integer time-out value means that the supervisor tells the child process to terminate by calling exit Child,shutdown and then wait for an exit signal with reason shutdown back from the child process.

If no exit signal is received within the specified number of milliseconds, the child process is unconditionally terminated using exit Child,kill. If the child process is another supervisor, the shutdown time must be set to infinity to give the subtree ample time to shut down. Setting the shutdown time to anything other than infinity for a child of type supervisor can cause a race condition where the child in question unlinks its own children, but fails to terminate them before it is killed.

It is also allowed to set it to infinity , if the child process is a worker. Be careful when setting the shutdown time to infinity when the child process is a worker. Because, in this situation, the termination of the supervision tree depends on the child process, it must be implemented in a safe way and its cleanup procedure must always return. Notice that all child processes implemented using the standard OTP behavior modules automatically adhere to the shutdown protocol. The shutdown key is optional.

If it is not specified, it defaults to if the child is of type worker and it defaults to infinity if the child is of type supervisor. The type key is optional. If it is not specified, it defaults to worker. The modules key is optional. Internally, the supervisor also keeps track of the pid Child of the child process, or undefined if no pid exists. The tuple format is kept for backward compatibility only. A map is preferred; see more details above.

Value undefined for A the argument list is only to be used internally in supervisor. If the restart type of the child is temporary , the process is never to be restarted and therefore there is no need to store the real argument list. Value undefined is then stored instead. Returns a property list see proplists containing the counts for each of the following elements of the supervisor's child specifications and managed processes:.

Tells supervisor SupRef to delete the child specification identified by Id.



0コメント

  • 1000 / 1000