erlang

Check active timers in Erlang

蓝咒 提交于 2019-12-05 01:24:20
Is there a simple way to get a list of all currently waiting timers started with erlang:send_after , erlang:apply_after , etc. in Erlang? For debugging purposes you can use dbg :). First create an ets table which will store all timer references. 1> ets:new(timer_dbg, ['public', 'named_table', 'bag']). timer_dbg Then create a dbg handler function, which checks for calls returning from erlang:send_after, and saves the returned timer reference to the table 2> Fun = fun({'trace', _Pid, 'return_from', {erlang, send_after, 3}, Ref}, []) -> 2> ets:insert(timer_dbg, {Ref}), []; 2> (_Msg, []) -> 2> []

Command 'generate' not understood or not applicable

淺唱寂寞╮ 提交于 2019-12-05 00:50:55
I am trying to run rebar generate to generate a release for an erlang rebar project and getting the following error. Any ideas what I am doing wrong? ./rebar generate Command 'generate' not understood or not applicable I am on OSX with erlang version Erlang R14B03 and below is my rebar.conf {lib_dirs, ["deps"]}. {sub_dirs, ["rel"]}. {deps, [ {folsom, ".*", {git, "git://github.com/boundary/folsom", "master"}} ]}. {require_otp_vsn, "R14|R15"}. {erl_opts, [ fail_on_warning, debug_info, warn_missing_spec ]}. {clean_files, ["*.eunit", "ebin/*.beam", "rel/graphsom"]}. {cover_enabled, true}. {eunit

Is there a clever way to give messages different priorities?

冷暖自知 提交于 2019-12-05 00:39:32
问题 I've been thinking, I would like to able to assign different messages different priorities when talking to an erlang process. I would like to be able to first handling high-priority messages, and then low-priority once. I've tried different approaches, approach 1: loop() -> receive {high, Msg} -> Do something with the message, loop() after 0 -> ok end, receive {low, Msg} -> Do something with the message, loop() after 0 -> loop() end. This does the job, but it is quiet slow. I guess the

How to uninstall or upgrade Erlang/OTP?

限于喜欢 提交于 2019-12-05 00:29:27
How can I uninstall Erlang/OTP which I use make install to build from source earlier. The install is pretty simple by using ./configure;make;make install; The reason to uninstall is that I want to upgrade from Erlang R15B01 to Erlang R15B03 . Now I have: # erl --version Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:2:2] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.9.1 (abort with ^G) 1> There is an option --prefix=path of script configure, where path is a path to directory where you want to install an application. For instance: ./configure --prefix=/opt/erlang-R15B01 Do not

golang学习第一篇 golang简介

主宰稳场 提交于 2019-12-05 00:09:11
golang简介 很久没写博客了,最近在学golang。为了总结学习经验,博客又派上用场了。 golang 是由谷歌的三位大牛发明并开源出来的,具体哪三位请大家自行搜索。 博主使用过这些计算机语言:C/C++、VB、C#、PHP、javascript、python、erlang。目前使用erlang从事即时通讯后台开发,期间也接触一些golang的开源项目。虽然很早就了解过golang,但没系统的学习过。 对比之前用过的计算机语言,golang有这些优点: 1、简单 golang里的变量可以不用定义而直接使用,golang会自行推导出变量的类型以及是否定义过。 例如: type Student struct{ name string age int } student := Student{ "Bob", 12} 在上面的代码中,:= 运算符会要求golang检查变量 student 是否被定义过。如果没有被定义,golang会自动定义,并赋值;如果该变量已经定义,那么golang会报错提示该变量已经被定义过。 从上面代码中我们还可以看到几个其他的优点:行尾不需要结束符(如C/C++的“;”, erlang的 “,” 等);定义变量(或新类型)时类型在变量(或新类型)名称的后面,这样做的好处是让开发者更加关心变量(或新类型)本身,而无需太关心其类型

Continuous integration server for Erlang code

橙三吉。 提交于 2019-12-04 22:36:14
问题 What kind of agile tools are you using for Erlang development? What continuous integration (CI) server are you using to build Erlang code? The only reference I got was from Quora question How do I integrate Erlang unit tests in Jenkins (Hudson)? . I am also interested in the nifty details of setting them up and making talk to each other. 回答1: If you want to do it using Jenkins, I have written a common test hook which generates JUnit XML output for your tests which Jenkins can use to produce

How set Erlang node name, when run an Erlang application by basho rebar from command line

非 Y 不嫁゛ 提交于 2019-12-04 22:28:23
问题 I have compiled my Erlang application by using basho rebar which makes an stand-alone escript executable file. I run it from command line like: ./myapp myconfig.config My questio is that how can I determine the Erlang node name that run my application. When in my application I run 'node()' command, it returns by default "nonode@nohost" but I want to give my name to that node (e.g. mynode@domain.com), so when I run 'node()' in my application, I like to see 'mynode@domain.com' instead of

How do you do selective receives in gen_servers?

一世执手 提交于 2019-12-04 22:26:55
问题 I ported most of my app to OTP behaviors, but I'm stuck. I can't figure out how to do selective receives using a gen_server. If none of the callback function clauses match a message, rather than putting the message back in the mailbox, it errors out! Now, everywhere I go, folks laud selective receives. Everywhere I go, folks laud OTP. Can it really be true that you can't have both at once? Doesn't this seem like a major, correctable shortcoming? How do erlang programmers handle this? EDIT

erlang 学习资源

青春壹個敷衍的年華 提交于 2019-12-04 22:24:41
Erlang语言绝对算得上是一种“小众”语言,但其未来的发展前景却是无法估量的,因为它可以解决传统语言很难解决的并行计算中的难题。Erlang是一种函数式(变量只能赋值一次)、强类型、动态类型(变量类型在运行时决定,代码需要编译后才能执行,与 Python,Ruby等不一样)、面向并发(Concurrency Oriented)的语言。最近公司有个项目刚好要用Erlang来开发,对这个语言产生了强烈的兴趣,下面收集一些Erlang常用的学习资源: Getting Started with Erlang. 开始使用Erlang Erlang Course . Erlang学习课程 Best practices for Erlang development : Erlang开发的最佳实践,推荐阅读,因为这篇文章介绍了一些不同的Erlang哲学,例如为什么Erlang不鼓励 “programming defensively” . Erlang教程:如何使用Erlang OTP创建应用 how to build an OTP application in Erlang . Thinking in Erlang , 思考Erlang,一个非常优秀的30页的面向C/C++/Java/Python,未曾使用函数式编程的开发者的介绍。 书写了务实编程(Pragmatic Programmer

How to send multicast messages and reuse a port in Erlang?

心已入冬 提交于 2019-12-04 22:22:07
问题 I have gotten a good start on my program, my first REAL Erlang program. I have it listening for messages, reading them and parsing them. I also have it sending them. The one little thing that is bothering me is I can't SEND on Port 5353, I have tried everything. All the other applications on my machine can listen AND send on port 5353, SubEthaEdit, iTunes, iChat. The solution MUST broadcast send on port 5353 and here is why. " If the source UDP port in a received Multicast DNS Query is not