ITeye博客

一个人的村庄

zhongwencool · 共 25 篇文章

Erlang 简单的节点互连

自己写的游戏跨服初步构架,以后再一点点完善,先记下时间线哈。 https://github.com/zhongwencool/NodeManager

2014-03-19 23:41 · erlang · OTP · 评论(0)

简单erlang节点互连实验

如果erlang:节点test1,test2互连接: 1.节点test1,test2 启动:分别在不同的shell上运行: erl -name test1 -setcookie "erlang_code_fun" erl -name test2 -setcookie "erlang_code_fun" 2.在节点1,节点2上运行: node()得到自己节点的名称。 观察与之互接的节点: nodes(). 节点test1:信息 节点test2:信息 3.把test1,test2节点连接起来: 可以看到双方的nodes()都返回了对方的节点名。 4. 起test3节点: erl -name te…

2014-03-10 15:53 · erlang · 评论(0)

Erlang OTP gen_event (1)

演示gen_event的运行过程: mod_event_manager.erl:事件管理器: mod_event_error_msg.erl: 错误日志事件:把错误放入对应的txt用。 %%%------------------------------------------------------------------- %%% @author zhongwencool@gmail.com %%% @copyright (C) 2014, <COMPANY> %%% @doc event manager center %%% %%% @end %%%-------------------…

2014-02-26 15:06 · erlang · OTP · gen_event · 评论(0)

Erlang OTP gen_event (0)

原英文文档:http://www.erlang.org/erldoc?q=&x=0&y=0 Tips:看到网页右边的搜索功能了么,保存这个实用网页吧。 一个实现事件处理功能行为模块,可以动态的删除和增加任意数量事件的事件管理器 (event_manager),事件管理器使用这个模块将实现一套标准的接口功能,包括跟踪和错误报告功能。同样他也适合OTP 监控树(supervision tree) 每个事件处理程序被实现为一个回调模块导出一组预定义的功能: 每一个事件处理程序都是一个回调模块,一个事件管理器必可以动态的增加和删除事件回调,所以gen_event 会比其它behaviours(gen…

2014-02-26 14:30 · erlang · OTP · gen_event · 评论(0)

window emacs esense 安装

window下安装esense 备忘: ] esense: * completion of names for modules, functions, records, macroses & fields in records; * jump to the files included with -include directive; * jump to the function's definition; * show of documentation for selected function, or show short description in tooltip. 可以完成各种智能…

2013-08-23 23:35 · emacs · 评论(0)

erlang efficient guide 3

*** 3 Common Caveats * 3常见的注意事项** Here we list a few modules and BIFs to watch out for, and not only from a performance point of view. 下面我们来看-看erlang的一些常用module和bif,不仅仅从性能的角度去考虑。 3.1 The timer module 3.1 timer模块 Creating timers using erlang:send_after/3 and erlang:start_timer/3 is much more efficie…

2013-08-19 22:19 · erlang · 评论(0)

erlang efficient guide 2

2 The Eight Myths of Erlang Performance 项目现在终于有点空闲时间了,看看erlang doc,觉得不错,就自己尝试看看,怕不是很理解就翻译出来。自己总结,感觉点很多,要成一个系统的去学习去不断的尝试才能理解这些原则和设计。慢慢去尝试吧。 注:【】内是我自己加的哦】 Some truths seem to live on well beyond their best-before date, perhaps because "information" spreads more rapidly from person-to-person faster th…

2013-08-18 01:02 · erlang · 评论(0)

fun还是如以前一样狂跩吊么?

fun这么好用。为什么老大在最近都说不要用? gen:call(PID,{func,fun() ->broadcast_to_whole_map(Record) end}). handle_call({func,F},_From,State) -> Reply = F(), {reply, Reply, State}. gen:call(PID,{server_module,broadcast_to_whole_map,[record]}). handle_call({server_module,broadcast_to_whole_map,[record]},_From,State) ->…

2013-08-16 22:26 · erlang · 评论(0)

emacs 的erlang-flymake

emacs 设置erlang-flymake erlang-flymake 是emacs自带的。可以看erlang-flymake.el里面的文件说明 核心在于:1)用erlc 来检查 2)用complie_file/2来脚本化定制 里面关键在于3个变量 ;; * erlang-flymake-get-code-path-dirs-function ;;检查目标文件 ;; * erlang-flymake-get-include-dirs-function ;;目标工程所在的include目录 ;; * erlang-flymake-extra-opts ;;编译的erlc 或compile…

2013-08-14 15:15 · erlang · emacs · 评论(0)

erlang ets

参见:http://www.cnblogs.com/me-sa/archive/2011/08/11/erlang0007.html 自己的看法: 1)如果一个表中数据太大,不要用ordered_set表。(这个表的好处在于可以按key来排序,但只能用这个唯一的key,实际工作中要按复杂的排序规则,所以不好用。 2)ets doc里面有大量的函数如next last, first基本是不用的。这些都是用c写的bif 不用于上层。只要用好ets.erl里面的上层导出就行了。---看看实现也适合。 3)...... %%ets的使用 %%ets:new/2 %% name_table------…

2013-07-22 23:08 · erlang · ets · 评论(0)

erlang的编程规范

Programming Rules and Conventions erlang的编程规范 ! erlang的基本体系: 从文件构造,进程,进程间联系,函数来说清楚整个构架。 Structure and Erlang Terminology Erlang systems are divided into modules. Modules are composed of functions and attributes. Functions are either only visible inside a module or they are exported i.e. they can al…

2013-03-26 17:17 · erlang · erlang · 评论(0)

Erlang------Mnesia

读erlang编程指南Mnesia笔记: 1.mnesia 是ets和dets上面封装一层的事务层。底层实现用的是这,重点加强了锁和分布式的适应。 2.不应使用mnesia的场合: 2.1 简单的键-值查询;-------- 最好用ets或dict 巨大的二进制数据:图片,音频;-------- 把每个记录和文件脱离,只记录文件名之类。(好像还有个开源数据库可用的?) 2.2 一个持续的日志;----------disk_log库 2.3 一个必须存储GB级别的数据库;--------这个不是首选,但是可以用来 缓存用户会话(在线)数据,定时写入到指定数据库中。 2.4 一直增长的大型数据档…

2013-03-25 12:49 · erlang · mnesia · mnesia · 评论(0)

进程环

编写一个程序,它生成N个进程并相连成环,。一旦启动,这些进程会绕环发送M个消息,然后当收到推出消息的时候正常终止。你可以调用rings:start(N,M,Msg)来启动环。 有两种策略可以完成这个练习,第一种是通过一个中央进程,它设置环并启动发送消息。第二种方法是换里面的新进程产生下一个进程。在编写程序的时候,请确保你的代码在每一个循环迭代中都有很多io:format声明,以检测到底什么发生了,什么没有发生。 http://www.sics.se/~joe/ericsson/du98024.html -module(zog). %% This is a test program that …

2013-03-18 16:48 · erlang · 评论(0)

匿名函数fun

lists:map(fun/1,). 小试匿名函数的好处。 那么怎么样去用呢:(照搬啊) 如要实现:test(Fun,).求对进行未定的操作:(这可怎么办啊,行为没定。。。。) 看看fun() ->end的妙用。 test(fun() -> X rem 2=:=0 end,List) .------》如何: test(Fun,List) -> lists:filter( Fun,List). 吊爆----- fun() ->end 的起源: **1.**如果我们要定义一下函数实现lists中元素 2 -----> 第一个想法: double() -> ; double() -> . 但是:对…

2012-12-15 16:12 · erlang · 评论(0)

听GTD 讲座:

GTD 邹鑫讲座: 1.为 什么要做时间管理 ?(不是为了效率,而是为了达到一定的境界,做一个武林高手) 2.为什么以前的各种时间管理为什么没有效果? 没有形成系统,没有套路,每件事都接流程走才快。 要一个系统对任务进行反应,不能直接反应简单的事(重要的事一般都是复杂的) GTD的核心 就是 心如止水,生活自如 : 3. GTD工作步骤: 收集-》加工-》搞定 1)收集: 时间管理的管理的是什么? -》承诺(不要拖延,负面情绪太多了): 大脑的特性:1) 你以为你忘记了,其实你还记得 2) 他乞求一致性, 现实和想法的一致性(不同时就会焦虑,焦虑就无所事事了) 用中间层来管理一切(和写程序一…

2012-12-08 22:13 · 生活 · 评论(0)