- 浏览: 982375 次
- 性别:
- 来自: 广州
最新评论
-
qingchuwudi:
有用,非常感谢!
erlang进程的优先级 -
zfjdiamond:
你好 这条命令 在那里输入??
你们有yum 我有LuaRocks -
simsunny22:
这个是在linux下运行的吧,在window下怎么运行escr ...
escript的高级特性 -
mozhenghua:
http://www.erlang.org/doc/apps/ ...
mnesia 分布协调的几个细节 -
fxltsbl:
A new record of 108000 HTTP req ...
Haproxy 1.4-dev2: barrier of 100k HTTP req/s crossed
这个文章用于记录我遇到的erlang编码中的技巧。
1.
%% http://lukego.livejournal.com/6753.html - that doesn't care about
%% the order in which results are received.
upmap(F, L) ->
Parent = self(),
Ref = make_ref(),
[receive {Ref, Result} -> Result end
|| _ <- [spawn(fun() -> Parent ! {Ref, F(X)} end) || X <- L]].
2.
http://www.erlang.org/ml-archive/erlang-questions/200301/msg00053.html
Good day,
I've surprisingly found Y-combinator very useful to solve practical
problem of writing recursive anonymous functions in Erlang.
Code were translated to Erlang from
http://www.ece.uc.edu/~franco/C511/html/Scheme/ycomb.html.
-module(lambda).
-export([y/1, mk_fact/0]).
%% Y-combinator itself
y(X) ->
F = fun (P) -> X(fun (Arg) -> (P(P))(Arg) end) end,
F(F).
%% Factorial example
mk_fact() ->
F =
fun (FA) ->
fun (N) ->
if (N == 0) -> 1;
true -> N * FA(N-1)
end
end
end,
y(F).
>From shell:
1> F = mk_fact().
#Fun<lambda.3.115879927>
2> F(5).
120
Best Regards,
Vladimir Sekissov
3.
1> string:concat("hello ", "world").
"hello world"
2> Module = list_to_atom("string").
string
3> Func = list_to_atom("concat").
concat
4> Module:Func("like", "this").
"likethis"
4.
prim模块IO操作与有同步和异步的版本。 但是inet_driver的实现全部是异步的的, 原因是内部使用反应器。
5. vanilla_driver最高效的读文件行的方法
1> erlang:open_port("hello.txt", [stream,line, in,eof]).
#Port<0.480>
2> flush().
Shell got {#Port<0.447>,{data,{eol,"hello"}}}
Shell got {#Port<0.447>,{data,{eol,"world"}}}
Shell got {#Port<0.447>,eof}
ok
6. Break模式下 'o' 查看port消息 未公开
7.
erts_debug:get_internal_state(node_and_dist_references).
/*
Returns an erlang term on this format:
{{node_references,
[{{Node, Creation}, Refc,
[{{ReferrerType, ID},
[{ReferenceType,References},
'...']},
'...']},
'...']},
{dist_references,
[{Node, Refc,
[{{ReferrerType, ID},
[{ReferenceType,References},
'...']},
'...']},
'...']}}
*/
8.
/*
* The "node_tables module" contain two (hash) tables: the node_table
* and the dist_table.
*
* The elements of the node_table represents a specific incarnation of
* an Erlang node and has {Nodename, Creation} pairs as keys. Elements
* in the node_table are referred to from node containers (see
* node_container_utils.h).
*
* The elements of the dist_table represents a (potential) connection
* to an Erlang node and has Nodename as key. Elements in the
* dist_table are either referred to from elements in the node_table
* or from the process or port structure of the entity controlling
* the connection.
*
* Both tables are garbage collected by reference counting.
*/
9.
%%%-----------------------------------------------------------------
%%% The process structure in kernel is as shown in the figure.
%%%
%%% ---------------
%%% | kernel_sup (A)|
%%% ---------------
%%% |
%%% -------------------------------
%%% | | |
%%% <std services> ------------- -------------
%%% (file,code, | erl_dist (A)| | safe_sup (1)|
%%% rpc, ...) ------------- -------------
%%% | |
%%% (net_kernel, (disk_log, pg2,
%%% auth, ...) ...)
%%%
%%% The rectangular boxes are supervisors. All supervisors except
%%% for kernel_safe_sup terminates the enitre erlang node if any of
%%% their children dies. Any child that can't be restarted in case
%%% of failure must be placed under one of these supervisors. Any
%%% other child must be placed under safe_sup. These children may
%%% be restarted. Be aware that if a child is restarted the old state
%%% and all data will be lost.
10。 shell内置命令rp用于看格式化的数据。 比如rp(processes()).
11. OTP-6850: Literal lists, tuples, and binaries are no longer constructed at run-time as they used to be, but are stored in a per-module constant pool. Literals that are used more than once are stored only once.
12. lc可以这样用。
Eshell V5.5.3.1 (abort with ^G)
1> Nums = [1,2,3], Nouns = [shoe,box,tape], Verbs = [].
[]
2> [Nums || Nums =/= []] ++ [Nouns || Nouns =/= []] ++ [Verbs || Verbs
=/= []].
[[1,2,3],[shoe,box,tape]]
13.
node_port(Node)->
{_, Owner}=lists:keyfind(owner, 1, element(2, net_kernel:node_info(Node))),
hd([P|| P<-erlang:ports(), erlang:port_info(P, connected) == {connected,Owner}])
14.
inet:setopts(node_port('xx@nd-desktop'), [{high_watermark, 131072}]).
15.
erl -kernel inet_default_connect_options '[{sndbuf, 1048576}, {high_watermark, 131072}]'
16. ICC 编译选项
export \
CC=icc \
CXX=icpc \
CFLAGS=" -O3 -ip -static -static-intel -no-gcc -no-prec-div -mp -unroll2 -xT" \
CXXFLAGS="-O3 -ip -static -static-intel -no-gcc -no-prec-div -mp -unroll2 -xT" \
LDFLAGS='-static -static-intel' \
LD=xild \
AR=xiar
17.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Load regulator
%%
%% This is a poor mans substitute for a fair scheduler algorithm
%% in the Erlang emulator. The mnesia_dumper process performs many
%% costly BIF invokations and must pay for this. But since the
%% Emulator does not handle this properly we must compensate for
%% this with some form of load regulation of ourselves in order to
%% not steal all computation power in the Erlang Emulator ans make
%% other processes starve. Hopefully this is a temporary solution.
18.
The magic commands in the shell. The full list is in the manual, but the ones I use most are:
* f() - forget all variables
* f(X) - forget X
* v(42) - recall result from line 42
* v(-1) - recall result from previous line
* rr(foo) - read record definitions from module foo
19.
beam_lib:chunks can get source code from a beam that was compiled with debug on which can be really usefull
{ok,{_,[{abstract_code,{_,AC}}]}} = beam_lib:chunks(Beam,[abstract_code]).
io:fwrite("~s~n", [erl_prettypr:format(erl_syntax:form_list(AC))]).
20.
ets:fun2ms(fun({Foo, _, Bar}) when Foo > 0 -> {Foo, Bar} end).
[{{'$1','_','$2'},[{'>','$1',0}],[{{'$1','$2'}}]}]
21.
# erl
Erlang R13B01 (erts-5.7.2) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.7.2 (abort with ^G)
1> H = fun ({trace, _, exit,S},_)-> io:format("got bad arg~p",[S]); (_,_)->skip end.
#Fun<erl_eval.12.113037538>
2> dbg:tracer(process, {H,null}).
{ok,<0.36.0>}
3> dbg:p(new, [procs]).
{ok,[{matched,nonode@nohost,0}]}
4>
4> spawn(fun() -> abs(x) end).
got bad arg{ok,[{call,2,
{atom,2,spawn},
[{'fun',2,
{clauses,
[{clause,2,[],[],
[{call,2,{atom,2,abs},[{atom,2,x}]}]}]}}]}],
3}got bad arg{badarg,[{erlang,abs,[x]}]}
=ERROR REPORT==== 13-Aug-2009::16:38:56 ===
Error in process <0.40.0> with exit value: {badarg,[{erlang,abs,[x]}]}
<0.40.0>
22;
The condition is specified by the user as a module name CModule and a function name CFunction. When a process reaches the breakpoint, CModule:CFunction(Bindings) will be evaluated. If and only if this function call returns true, the process will stop. If the function call returns false, the breakpoint will be silently ignored.
Bindings is a list of variable bindings. Use the function int:get_binding(Variable,Bindings) to retrieve the value of Variable (given as an atom). The function returns unbound or {value,Value}.
22.
export ERL_TOP=/usr/lib/erlang/
dialyzer --build_plt --output_plt $HOME/.dialyzer_otp.plt -r $ERL_TOP/lib/stdlib/ebin
$ERL_TOP/lib/kernel/ebin $ERL_TOP/lib/mnesia/ebin $ERL_TOP/lib/ssl/ebin
$ERL_TOP/lib/asn1/ebin $ERL_TOP/lib/compiler/ebin $ERL_TOP/lib/crypto/ebin
$ERL_TOP/lib/syntax_tools/ebin $ERL_TOP/lib/inets/ebin $ERL_TOP/lib/sasl/ebin
$ERL_TOP/lib/odbc/ebin
23. 查看系统的上下文切换
k# cat csw.stp
#!/usr/local/bin/stap -k
global lasttime, times, execnames, switches, csw
probe kernel.function("context_switch") {
#probe scheduler.cpu_off{
switches ++ # count number of context switches
now = get_cycles()
times[pid()] += now-lasttime # accumulate cycles spent in process
execnames[pid()] = execname() # remember name of pid
csw[pid()]++
lasttime = now
}
probe timer.ms(3000) {
printf ("\n%10s %30s %20s %20s (%d switches)\n",
"pid", "execname", "cycles", "csw", switches);
foreach ([pid] in times-) # sort in decreasing order of cycle-count
printf ("%10d %30s %20d %20d\n", pid, execnames[pid], times[pid], csw[pid]);
# clear data for next report
delete times
delete execnames
delete csw
switches = 0
}
probe begin {
lasttime = get_cycles()
}
24.
root@nd-desktop:~/test/arksea# cat test.erl
-module(test).
-export([start/0]).
start()->
{ok, Sock} = gen_tcp:listen(0, []),
{ok, Handle} = inet:getfd(Sock),
Command = "erl -noshell -s child -handle " ++ integer_to_list(Handle),
Child = case (catch open_port({spawn, Command}, [in, {line, 256}])) of
{'EXIT', Reason}->
io:format("open child error, reason ~p~n", [Reason]),
halt(1);
Port-> Port
end,
register(?MODULE, self()),
loop(Child).
loop(Child)->
receive
{Child, {data, Result}} ->
io:format("child say ~p~n", [Result]),
loop(Child);
stop->
halt(0)
end.
root@nd-desktop:~/test/arksea# cat child.erl
-module(child).
-export([start/0]).
start()->
{ok, [[HandleArg|_]|_]} = init:get_argument(handle),
Handle = list_to_integer(HandleArg),
io:format("handle: ~w~n", [Handle]),
{ok,Socket} = gen_tcp:fdopen(Handle, []),
io:format("socket: ~p~n", [Socket]),
halt(0).
25. Regarding the GC, consider what it has to work with. You are
building a very large data structure in a tight loop. The
process will continuously run out of heap, triggering the GC.
The GC will copy live data (which is going to be most of it)
to another copy of the heap. If that's not enough, it will
run a fullsweep, also looking at data that survived the
previous GC (no garbage there, since the list just keeps
growing). This creates yet another heap copy.
Finally, it does a resize of the heap, if necessary.
26. 反编译
f(),{ok, {_, [{abstract_code, {_,Abs}}]}} = beam_lib:chunks("xxx.beam", [abstract_code]), io:fwrite("~s~n", [erl_prettypr:format(erl_syntax:form_list(Abs))]).
27.
打印 usage
erl +
是不是你的文件很大 你可以试验几行的 这个是c实现的 应该没有问题的。PS 你在那个平台下?linux?
1.
%% http://lukego.livejournal.com/6753.html - that doesn't care about
%% the order in which results are received.
upmap(F, L) ->
Parent = self(),
Ref = make_ref(),
[receive {Ref, Result} -> Result end
|| _ <- [spawn(fun() -> Parent ! {Ref, F(X)} end) || X <- L]].
2.
http://www.erlang.org/ml-archive/erlang-questions/200301/msg00053.html
Good day,
I've surprisingly found Y-combinator very useful to solve practical
problem of writing recursive anonymous functions in Erlang.
Code were translated to Erlang from
http://www.ece.uc.edu/~franco/C511/html/Scheme/ycomb.html.
-module(lambda).
-export([y/1, mk_fact/0]).
%% Y-combinator itself
y(X) ->
F = fun (P) -> X(fun (Arg) -> (P(P))(Arg) end) end,
F(F).
%% Factorial example
mk_fact() ->
F =
fun (FA) ->
fun (N) ->
if (N == 0) -> 1;
true -> N * FA(N-1)
end
end
end,
y(F).
>From shell:
1> F = mk_fact().
#Fun<lambda.3.115879927>
2> F(5).
120
Best Regards,
Vladimir Sekissov
3.
1> string:concat("hello ", "world").
"hello world"
2> Module = list_to_atom("string").
string
3> Func = list_to_atom("concat").
concat
4> Module:Func("like", "this").
"likethis"
4.
prim模块IO操作与有同步和异步的版本。 但是inet_driver的实现全部是异步的的, 原因是内部使用反应器。
5. vanilla_driver最高效的读文件行的方法
1> erlang:open_port("hello.txt", [stream,line, in,eof]).
#Port<0.480>
2> flush().
Shell got {#Port<0.447>,{data,{eol,"hello"}}}
Shell got {#Port<0.447>,{data,{eol,"world"}}}
Shell got {#Port<0.447>,eof}
ok
6. Break模式下 'o' 查看port消息 未公开
7.
erts_debug:get_internal_state(node_and_dist_references).
/*
Returns an erlang term on this format:
{{node_references,
[{{Node, Creation}, Refc,
[{{ReferrerType, ID},
[{ReferenceType,References},
'...']},
'...']},
'...']},
{dist_references,
[{Node, Refc,
[{{ReferrerType, ID},
[{ReferenceType,References},
'...']},
'...']},
'...']}}
*/
8.
/*
* The "node_tables module" contain two (hash) tables: the node_table
* and the dist_table.
*
* The elements of the node_table represents a specific incarnation of
* an Erlang node and has {Nodename, Creation} pairs as keys. Elements
* in the node_table are referred to from node containers (see
* node_container_utils.h).
*
* The elements of the dist_table represents a (potential) connection
* to an Erlang node and has Nodename as key. Elements in the
* dist_table are either referred to from elements in the node_table
* or from the process or port structure of the entity controlling
* the connection.
*
* Both tables are garbage collected by reference counting.
*/
9.
%%%-----------------------------------------------------------------
%%% The process structure in kernel is as shown in the figure.
%%%
%%% ---------------
%%% | kernel_sup (A)|
%%% ---------------
%%% |
%%% -------------------------------
%%% | | |
%%% <std services> ------------- -------------
%%% (file,code, | erl_dist (A)| | safe_sup (1)|
%%% rpc, ...) ------------- -------------
%%% | |
%%% (net_kernel, (disk_log, pg2,
%%% auth, ...) ...)
%%%
%%% The rectangular boxes are supervisors. All supervisors except
%%% for kernel_safe_sup terminates the enitre erlang node if any of
%%% their children dies. Any child that can't be restarted in case
%%% of failure must be placed under one of these supervisors. Any
%%% other child must be placed under safe_sup. These children may
%%% be restarted. Be aware that if a child is restarted the old state
%%% and all data will be lost.
10。 shell内置命令rp用于看格式化的数据。 比如rp(processes()).
11. OTP-6850: Literal lists, tuples, and binaries are no longer constructed at run-time as they used to be, but are stored in a per-module constant pool. Literals that are used more than once are stored only once.
12. lc可以这样用。
Eshell V5.5.3.1 (abort with ^G)
1> Nums = [1,2,3], Nouns = [shoe,box,tape], Verbs = [].
[]
2> [Nums || Nums =/= []] ++ [Nouns || Nouns =/= []] ++ [Verbs || Verbs
=/= []].
[[1,2,3],[shoe,box,tape]]
13.
node_port(Node)->
{_, Owner}=lists:keyfind(owner, 1, element(2, net_kernel:node_info(Node))),
hd([P|| P<-erlang:ports(), erlang:port_info(P, connected) == {connected,Owner}])
14.
inet:setopts(node_port('xx@nd-desktop'), [{high_watermark, 131072}]).
15.
erl -kernel inet_default_connect_options '[{sndbuf, 1048576}, {high_watermark, 131072}]'
16. ICC 编译选项
export \
CC=icc \
CXX=icpc \
CFLAGS=" -O3 -ip -static -static-intel -no-gcc -no-prec-div -mp -unroll2 -xT" \
CXXFLAGS="-O3 -ip -static -static-intel -no-gcc -no-prec-div -mp -unroll2 -xT" \
LDFLAGS='-static -static-intel' \
LD=xild \
AR=xiar
17.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Load regulator
%%
%% This is a poor mans substitute for a fair scheduler algorithm
%% in the Erlang emulator. The mnesia_dumper process performs many
%% costly BIF invokations and must pay for this. But since the
%% Emulator does not handle this properly we must compensate for
%% this with some form of load regulation of ourselves in order to
%% not steal all computation power in the Erlang Emulator ans make
%% other processes starve. Hopefully this is a temporary solution.
18.
The magic commands in the shell. The full list is in the manual, but the ones I use most are:
* f() - forget all variables
* f(X) - forget X
* v(42) - recall result from line 42
* v(-1) - recall result from previous line
* rr(foo) - read record definitions from module foo
19.
beam_lib:chunks can get source code from a beam that was compiled with debug on which can be really usefull
{ok,{_,[{abstract_code,{_,AC}}]}} = beam_lib:chunks(Beam,[abstract_code]).
io:fwrite("~s~n", [erl_prettypr:format(erl_syntax:form_list(AC))]).
20.
ets:fun2ms(fun({Foo, _, Bar}) when Foo > 0 -> {Foo, Bar} end).
[{{'$1','_','$2'},[{'>','$1',0}],[{{'$1','$2'}}]}]
21.
# erl
Erlang R13B01 (erts-5.7.2) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.7.2 (abort with ^G)
1> H = fun ({trace, _, exit,S},_)-> io:format("got bad arg~p",[S]); (_,_)->skip end.
#Fun<erl_eval.12.113037538>
2> dbg:tracer(process, {H,null}).
{ok,<0.36.0>}
3> dbg:p(new, [procs]).
{ok,[{matched,nonode@nohost,0}]}
4>
4> spawn(fun() -> abs(x) end).
got bad arg{ok,[{call,2,
{atom,2,spawn},
[{'fun',2,
{clauses,
[{clause,2,[],[],
[{call,2,{atom,2,abs},[{atom,2,x}]}]}]}}]}],
3}got bad arg{badarg,[{erlang,abs,[x]}]}
=ERROR REPORT==== 13-Aug-2009::16:38:56 ===
Error in process <0.40.0> with exit value: {badarg,[{erlang,abs,[x]}]}
<0.40.0>
22;
The condition is specified by the user as a module name CModule and a function name CFunction. When a process reaches the breakpoint, CModule:CFunction(Bindings) will be evaluated. If and only if this function call returns true, the process will stop. If the function call returns false, the breakpoint will be silently ignored.
Bindings is a list of variable bindings. Use the function int:get_binding(Variable,Bindings) to retrieve the value of Variable (given as an atom). The function returns unbound or {value,Value}.
22.
export ERL_TOP=/usr/lib/erlang/
dialyzer --build_plt --output_plt $HOME/.dialyzer_otp.plt -r $ERL_TOP/lib/stdlib/ebin
$ERL_TOP/lib/kernel/ebin $ERL_TOP/lib/mnesia/ebin $ERL_TOP/lib/ssl/ebin
$ERL_TOP/lib/asn1/ebin $ERL_TOP/lib/compiler/ebin $ERL_TOP/lib/crypto/ebin
$ERL_TOP/lib/syntax_tools/ebin $ERL_TOP/lib/inets/ebin $ERL_TOP/lib/sasl/ebin
$ERL_TOP/lib/odbc/ebin
23. 查看系统的上下文切换
k# cat csw.stp
#!/usr/local/bin/stap -k
global lasttime, times, execnames, switches, csw
probe kernel.function("context_switch") {
#probe scheduler.cpu_off{
switches ++ # count number of context switches
now = get_cycles()
times[pid()] += now-lasttime # accumulate cycles spent in process
execnames[pid()] = execname() # remember name of pid
csw[pid()]++
lasttime = now
}
probe timer.ms(3000) {
printf ("\n%10s %30s %20s %20s (%d switches)\n",
"pid", "execname", "cycles", "csw", switches);
foreach ([pid] in times-) # sort in decreasing order of cycle-count
printf ("%10d %30s %20d %20d\n", pid, execnames[pid], times[pid], csw[pid]);
# clear data for next report
delete times
delete execnames
delete csw
switches = 0
}
probe begin {
lasttime = get_cycles()
}
24.
root@nd-desktop:~/test/arksea# cat test.erl
-module(test).
-export([start/0]).
start()->
{ok, Sock} = gen_tcp:listen(0, []),
{ok, Handle} = inet:getfd(Sock),
Command = "erl -noshell -s child -handle " ++ integer_to_list(Handle),
Child = case (catch open_port({spawn, Command}, [in, {line, 256}])) of
{'EXIT', Reason}->
io:format("open child error, reason ~p~n", [Reason]),
halt(1);
Port-> Port
end,
register(?MODULE, self()),
loop(Child).
loop(Child)->
receive
{Child, {data, Result}} ->
io:format("child say ~p~n", [Result]),
loop(Child);
stop->
halt(0)
end.
root@nd-desktop:~/test/arksea# cat child.erl
-module(child).
-export([start/0]).
start()->
{ok, [[HandleArg|_]|_]} = init:get_argument(handle),
Handle = list_to_integer(HandleArg),
io:format("handle: ~w~n", [Handle]),
{ok,Socket} = gen_tcp:fdopen(Handle, []),
io:format("socket: ~p~n", [Socket]),
halt(0).
25. Regarding the GC, consider what it has to work with. You are
building a very large data structure in a tight loop. The
process will continuously run out of heap, triggering the GC.
The GC will copy live data (which is going to be most of it)
to another copy of the heap. If that's not enough, it will
run a fullsweep, also looking at data that survived the
previous GC (no garbage there, since the list just keeps
growing). This creates yet another heap copy.
Finally, it does a resize of the heap, if necessary.
26. 反编译
f(),{ok, {_, [{abstract_code, {_,Abs}}]}} = beam_lib:chunks("xxx.beam", [abstract_code]), io:fwrite("~s~n", [erl_prettypr:format(erl_syntax:form_list(Abs))]).
27.
打印 usage
erl +
评论
8 楼
mryufeng
2009-08-04
windows平台估计有问题 在linux下很稳定! 因为otp的小组的开发平台是solaris
7 楼
whrllm
2009-08-04
结果:
2> erlang:open_port("test1.txt" , [stream , line , in , eof]).
#Port<0.439>
3> flush().
Shell got {#Port<0.439>,{data,{eol,"boundaryuuid "}}}
Shell got {#Port<0.439>,{data,{eol,"EF1D2EA88A3ED5D6811230262922518"}}}
Shell got {#Port<0.439>,{data,{eol,"EF1D2EA88A3ED5D6811230262922519"}}}
……
Shell got {#Port<0.439>,{data,{eol,"boundaryuuid "}}}
Shell got {#Port<0.439>,{data,{eol,"EF1D2EA88A3ED5D6811230262922518"}}}
Shell got {#Port<0.439>,{data,{eol,"EF1D2EA88A3ED5D6811230262922519"}}}
……
Shell got {#Port<0.439>,{data,{eol,"boundaryuuid "}}}
Shell got {#Port<0.439>,{data,{eol,"EF1D2EA88A3ED5D6811230262922518"}}}
Shell got {#Port<0.439>,{data,{eol,"EF1D2EA88A3ED5D6811230262922519"}}}
Shell got {#Port<0.439>,{data,{eol,"EF1D2EA88A3ED5D6811230262922520"}}}
……
2> erlang:open_port("test1.txt" , [stream , line , in , eof]).
#Port<0.439>
3> flush().
Shell got {#Port<0.439>,{data,{eol,"boundaryuuid "}}}
Shell got {#Port<0.439>,{data,{eol,"EF1D2EA88A3ED5D6811230262922518"}}}
Shell got {#Port<0.439>,{data,{eol,"EF1D2EA88A3ED5D6811230262922519"}}}
……
Shell got {#Port<0.439>,{data,{eol,"boundaryuuid "}}}
Shell got {#Port<0.439>,{data,{eol,"EF1D2EA88A3ED5D6811230262922518"}}}
Shell got {#Port<0.439>,{data,{eol,"EF1D2EA88A3ED5D6811230262922519"}}}
……
Shell got {#Port<0.439>,{data,{eol,"boundaryuuid "}}}
Shell got {#Port<0.439>,{data,{eol,"EF1D2EA88A3ED5D6811230262922518"}}}
Shell got {#Port<0.439>,{data,{eol,"EF1D2EA88A3ED5D6811230262922519"}}}
Shell got {#Port<0.439>,{data,{eol,"EF1D2EA88A3ED5D6811230262922520"}}}
……
6 楼
whrllm
2009-08-04
文件内容:
boundaryuuid
EF1D2EA88A3ED5D6811230262922518
EF1D2EA88A3ED5D6811230262922519
EF1D2EA88A3ED5D6811230262922520
EF1D2EA88A3ED5D6811230262922521
EF1D2EA88A3ED5D6811230262922522
EF1D2EA88A3ED5D6811230262922523
EF1D2EA88A3ED5D6811230262922524
EF1D2EA88A3ED5D6811230262922525
EF1D2EA88A3ED5D6811230262922526
用的是windows的平台,几乎参数都用过了,都是出现循环读取/没有{Port, eof}这个标志,你可以试试看,R13A
boundaryuuid
EF1D2EA88A3ED5D6811230262922518
EF1D2EA88A3ED5D6811230262922519
EF1D2EA88A3ED5D6811230262922520
EF1D2EA88A3ED5D6811230262922521
EF1D2EA88A3ED5D6811230262922522
EF1D2EA88A3ED5D6811230262922523
EF1D2EA88A3ED5D6811230262922524
EF1D2EA88A3ED5D6811230262922525
EF1D2EA88A3ED5D6811230262922526
用的是windows的平台,几乎参数都用过了,都是出现循环读取/没有{Port, eof}这个标志,你可以试试看,R13A
5 楼
mryufeng
2009-08-04
whrllm 写道
为什么我使用了第5点的方法,它会循环的读取行,不停的读,而且没有发送{Port, eof}这个标记? 我的版本是R13A,谢谢
是不是你的文件很大 你可以试验几行的 这个是c实现的 应该没有问题的。PS 你在那个平台下?linux?
4 楼
whrllm
2009-08-04
为什么我使用了第5点的方法,它会循环的读取行,不停的读,而且没有发送{Port, eof}这个标记? 我的版本是R13A,谢谢
3 楼
litaocheng
2009-04-11
忘记这个原则了.
F出错是调用者的事情. 让他自己去管理吧..
F出错是调用者的事情. 让他自己去管理吧..
2 楼
mryufeng
2009-04-11
fail fast,通用的例程不卷入这个判断比较好。
1 楼
litaocheng
2009-04-11
...
|| _ <- [spawn(fun() -> Parent ! {Ref, F(X)} end) || X <- L]].
是不是 Parent ! {Ref, catch F(X)} 比较稳健泥。。呵呵
|| _ <- [spawn(fun() -> Parent ! {Ref, F(X)} end) || X <- L]].
是不是 Parent ! {Ref, catch F(X)} 比较稳健泥。。呵呵
发表评论
-
OTP R14A今天发布了
2010-06-17 14:36 2677以下是这次发布的亮点,没有太大的性能改进, 主要是修理了很多B ... -
R14A实现了EEP31,添加了binary模块
2010-05-21 15:15 3030Erlang的binary数据结构非常强大,而且偏向底层,在作 ... -
如何查看节点的可用句柄数目和已用句柄数
2010-04-08 03:31 4814很多同学在使用erlang的过程中, 碰到了很奇怪的问题, 后 ... -
获取Erlang系统信息的代码片段
2010-04-06 21:49 3475从lib/megaco/src/tcp/megaco_tcp_ ... -
iolist跟list有什么区别?
2010-04-06 20:30 6529看到erlang-china.org上有个 ... -
erlang:send_after和erlang:start_timer的使用解释
2010-04-06 18:31 8386前段时间arksea 同学提出这个问题, 因为文档里面写的很不 ... -
Latest news from the Erlang/OTP team at Ericsson 2010
2010-04-05 19:23 2013参考Talk http://www.erlang-factor ... -
对try 异常 运行的疑问,为什么出现两种结果
2010-04-05 19:22 2842郎咸武<langxianzhe@163.com> ... -
Erlang ERTS Async基础设施
2010-03-19 00:03 2517其实Erts的Async做的很不错的, 相当的完备, 性能又高 ... -
CloudI 0.0.9 Released, A Cloud as an Interface
2010-03-09 22:32 2476基于Erlang的云平台 看了下代码 质量还是不错的 完成了不 ... -
Memory matters - even in Erlang (再次说明了了解内存如何工作的必要性)
2010-03-09 20:26 3439原文地址:http://www.lshift.net/blog ... -
Some simple examples of using Erlang’s XPath implementation
2010-03-08 23:30 2050原文地址 http://www.lshift.net/blog ... -
lcnt 环境搭建
2010-02-26 16:19 2614抄书:otp_doc_html_R13B04/lib/tool ... -
Erlang强大的代码重构工具 tidier
2010-02-25 16:22 2486Jan 29, 2010 We are very happy ... -
[Feb 24 2010] Erlang/OTP R13B04 has been released
2010-02-25 00:31 1387Erlang/OTP R13B04 has been rele ... -
R13B04 Installation
2010-01-28 10:28 1390R13B04后erlang的源码编译为了考虑移植性,就改变了编 ... -
Running tests
2010-01-19 14:51 1486R13B03以后 OTP的模块加入了大量的测试模块,这些模块都 ... -
R13B04在细化Binary heap
2010-01-14 15:11 1508从github otp的更新日志可以清楚的看到otp R13B ... -
R13B03 binary vheap有助减少binary内存压力
2009-11-29 16:07 1668R13B03 binary vheap有助减少binary内存 ... -
erl_nif 扩展erlang的另外一种方法
2009-11-26 01:02 3218我们知道扩展erl有2种方法, driver和port. 这2 ...
相关推荐
Erlang是一种高级编程语言,特别适用于并发、分布式和实时计算系统。它的设计目标是创建一个高度可靠且容错的环境,广泛应用于电信、金融、在线游戏和消息队列服务等领域。Erlang由爱立信开发,其核心概念包括进程...
Erlang是一种高级编程语言,特别为并发、分布式和实时计算设计,由Ericsson公司开发,主要用于构建大规模、高可用性的系统。在标题"erlang-22.3-1.el7.x86_64.rpm"中,我们可以解读出几个关键信息: 1. **版本号**...
此外,Erlang具有强大的热代码替换功能,可以在不中断服务的情况下更新运行中的代码,这对于需要持续运行的服务器如RabbitMQ来说至关重要。 RabbitMQ的安装通常需要先确保系统中有Erlang环境,因为它是RabbitMQ运行...
erlang-20.3-1.el7.centos.x86_64.rpm
Erlang是一种高级编程语言,特别为并发、分布式计算和容错设计,广泛应用于网络通信、实时系统和大型分布式计算环境中。最新版的Erlang是23.3.4.3-1.el7.x86_64.rpm,这个版本针对CentOS 7进行了优化。Erlang以其轻...
erlang-24.0.3-1.el8.x86_64.rpm资源
erlang-21.3-1.el7.x86_64.rpm rabbitmq基础语言环境。
erlang-24.3.3-1.el9.x86_64.rpm centos
erlang-19.0.4-1.el7.centos.x86_64.rpm ,官网的正式包
erlang-21.3.8.11-1.el6.x86_64.rpm
erlang-21.3.1-1.el7.x86_64.rpm
erlang-20.3.8.17-1.el7.centos.x86_64
Erlang是一种通用的面向并发的编程语言,它由瑞典电信设备制造商爱立信所辖的CS-Lab开发,目的是创造一种可以应对大规模并发活动的编程语言和运行环境。文件(erlang-23.1.1-1.el7.x86_64.rpm)是Erlang语言是安装包,...
erlang-xmerl-23.0.2-2.el7.x86_64.rpm,rabbitMQ安装需要依赖此环境。Erlang 是一种多用途编程语言,主要用于开发并发和分布式系统。它最初是一种专有的编程语言,Ericsson 使用它来开发电话和通信应用程序。
Erlang,作为一门强大的编程语言,源自于20世纪80年代的瑞典,由爱立信公司的计算机科学实验室(CS-Lab)设计并开发。它的诞生初衷是为了满足电信行业中日益增长的并发处理需求,尤其是在分布式系统和实时系统中的...
erlang-23.2.1-1.el7.x86_64.rpm
Erlang是一款强大的编程语言,尤其在分布式计算、并发处理和实时系统方面有着出色的表现。标题中的"erlang-19.0.4-1.el7.centos.x86_64.zip"揭示了我们讨论的是Erlang的一个特定版本——19.0.4,该版本针对的是Linux...
erlang-21.3.8.15-1.el7.x86_64.rpm
erlang-22.1.4-1.el7.x86_64.rpm rabbitmq基础语言环境。