码迷,mamicode.com
首页 > 其他好文 > 详细

Erlang 热更新机制

时间:2015-06-17 23:11:23      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:

Current and Old Code

The code of a module can exists in two variants in a system: current code and old code. When a module is loaded into the system for the first time, the code of the module becomes ‘current‘ and the global export table is updated with references to all functions exported from the module.

If then a new instance of the module is loaded (perhaps because of the correction of an error), then the code of the previous instance becomes ‘old‘, and all export entries referring to the previous instance are removed. After that the new instance is loaded as if it was loaded for the first time, as described above, and becomes ‘current‘.

Both old and current code for a module are valid, and may even be evaluated concurrently. The difference is that exported functions in old code are unavailable. Hence there is no way to make a global call to an exported function in old code, but old code may still be evaluated because of processes lingering in it.

If a third instance of the module is loaded, the code server will remove (purge) the old code and any processes lingering in it will be terminated. Then the third instance becomes ‘current‘ and the previously current code becomes ‘old‘.

For more information about old and current code, and how to make a process switch from old to current code, refer to Erlang Reference Manual.

Erlang 热更新机制

标签:

原文地址:http://www.cnblogs.com/huangriq/p/4584500.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!