Erlang进程池 Worker Pool

码农软件 · 软件分类 · 常用工具包 · 2019-08-14 22:43:45

软件介绍

Worker Pool 是一个Erlang进程池,其中的工作进程是Erlang的gen server模式进程。

Worker Pool的目标是非常简单: 提供以透明的方式管理一批工作进程并且对分配到池中的任务尽最大努力实现负载均衡。

一个 Echo 服务器示例:

-module(echo_server).
-author('elbrujohalcon@inaka.net').

-behaviour(gen_server).

%% gen_server callbacks
-export([init/1, terminate/2, code_change/3,
         handle_call/3, handle_cast/2, handle_info/2]).

-dialyzer([no_behaviours]).

%%%===================================================================
%%% callbacks
%%%===================================================================
-spec init(Something) -> Something.
init(Something) -> Something.

-spec terminate(Any, term()) -> Any.
terminate(Reason, _State) -> Reason.

-spec code_change(string(), State, any()) -> {ok, State}.
code_change(_OldVsn, State, _Extra) -> {ok, State}.

-spec handle_info(timeout | Info, term()) -> {noreply, timeout} | Info.
handle_info(timeout, _State) -> {noreply, timeout};
handle_info(Info, _State) -> Info.

-spec handle_cast(Cast, term()) -> Cast.
handle_cast(Cast, _State) -> Cast.

-type from() :: {pid(), reference()}.
-spec handle_call(state | Call, from(), State) -> {reply, State, State} | Call.
handle_call(state, _From, State) -> {reply, State, State};
handle_call(Call, _From, _State) -> Call.

本文地址:https://codercto.com/soft/d/12383.html

雷军

雷军

蔡艳鹏 / 2012-12 / 29.80元

《雷军:人因梦想而伟大》内容简介:人生充满着期待,梦想连接着未来。雷军一直有个梦,就是建一个受世人尊敬的企业。他不仅建立了属于自己的受人尊敬的企业,也在帮助别人实现心中的梦想。雷军可以说是创业者、职场人奋斗的榜样,从他在金山的不折不挠,在投资界的百投百中,到小米的成功……无不充满传奇,让无数人争相效仿。一起来看看 《雷军》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

html转js在线工具
html转js在线工具

html转js在线工具