首页 > 其他分享 >无涯教程-Erlang - register函数

无涯教程-Erlang - register函数

时间:2023-12-07 19:32:18浏览次数:35  
标签:kernel error register 无涯 server call sup Erlang

这用于在系统中注册进程。

register - 语法

register(atom,pid)
  • atom - 这是要赋予该过程的注册名称。

  • pid    - 这是需要绑定到原子的进程ID。

register - 示例

-module(helloLearnfk). 
-export([start/0, call/2]). 

call(Arg1, Arg2) -> 
   io:fwrite("~p~n",[Arg1]). 

start() -> 
   Pid=spawn(?MODULE, call, ["hello", "process"]), 
   register(myprocess, Pid), 
   io:fwrite("~p~n",[registered()]).

当我们运行上述程序时,我们将得到以下输出。

[kernel_safe_sup,rex,erl_prim_loader,kernel_sup,inet_db,global_name_server,
code_server,file_server_2,application_controller,init,user,standard_error,
global_group,error_logger,standard_error_sup,myprocess]
"hello"

参考链接

https://www.learnfk.com/erlang/erlang-register.html

标签:kernel,error,register,无涯,server,call,sup,Erlang
From: https://blog.51cto.com/u_14033984/8727131

相关文章

  • 无涯教程-Erlang - is_pid函数
    此方法用于确定进程ID是否存在。is_pid-语法Is_pid(processid)processid  - 这是需要检查的进程ID,是否存在。is_pid-返回值如果进程ID存在,则返回true,否则将返回false。-module(helloLearnfk).-export([start/0,call/2]).call(Arg1,Arg2)->io:format("......
  • 无涯教程-Erlang - binary_to_list函数
    此方法用于将二进制值转换为列表。binary_to_list-语法binary_to_list(binaryvalue)binaryvalue- 这是需要转换为列表的二进制值。binary_to_list-返回值返回列表。-module(helloLearnfk).-export([start/0]).start()->io:fwrite("~p~n",[binary_to_lis......
  • 无涯教程-Erlang - is_binary函数
    此方法用于检查位串是否确实是二进制值。is_binary-语法is_binary(bitstring)bitstring-这是需要检查其是否为二进制的位串。is_binary-返回值如果位串是二进制值,则返回true;否则返回false。-module(helloLearnfk).-export([start/0]).start()->io:fwrite("......
  • 无涯教程-Erlang - term_to_binary函数
    此方法用于将术语转换为二进制。term_to_binary-语法term_to_binary(term)term-这是需要转换为二进制值的术语值。term_to_binary-返回值根据指定的术语返回一个二进制值。-module(helloLearnfk).-export([start/0]).start()->io:fwrite("~p~n",[term_to......
  • 无涯教程-Erlang - memory函数
    返回一个列表,其中包含有关由Erlang动态分配的内存的信息,该列表的每个元素都是一个元组{Type,Size},第一个元素Type是描述内存类型的原子。memory-语法memory()memory-返回值返回一个列表,其中包含有关由Erlang仿真器动态分配的内存的信息。-module(helloLearnfk).-export......
  • 无涯教程-Erlang - element函数
    该方法返回元组中的第Nth元素。element-语法element(N,Tuple)N    -元组中需要返回的位置。Tuple -需要为其返回第N元素的元组。element-返回值该方法返回元组中的第Nth元素。-module(helloLearnfk).-export([start/0]).start()->io:......
  • 无涯教程-Erlang - tuple_to_list函数
    此方法将元组转换为列表。tuple_to_list-语法tuple_to_list(list)list - 这是需要转换为列表的元组。tuple_to_list-返回值根据提供的元组返回一个列表。-module(helloLearnfk).-export([start/0]).start()->io:fwrite("~w",[tuple_to_list({1,2,3})]).......
  • 无涯教程-Erlang - list_to_tuple函数
    此方法是将列表转换为元组。list_to_tuple-语法list_to_tuple(list)list - 这是需要转换为元组的列表。list_to_tuple-返回值根据提供的列表返回一个元组。-module(helloLearnfk).-export([start/0]).start()->io:fwrite("~w",[list_to_tuple([1,2,3])])......
  • 无涯教程-Erlang - is_tuple函数
    此方法用于确定所提供的术语确实是元组。is_tuple-语法is_tuple(tuple)tuple-这是要验证的元组是否真的是元组。is_tuple-返回值如果确实输入的值是元组,则返回true,否则将返回false。-module(helloLearnfk).-export([start/0]).start()->P={john,24,{june,2......
  • 无涯教程-Erlang - keys函数
    此方法用于从Map返回所有键。keys-语法keys(map)map - 这是需要为其返回所有键的映射。keys-返回值返回Map中的键列表。-module(helloLearnfk).-export([start/0]).start()->Lst1=[{"a",1},{"b",2},{"c",3}],Map1=maps:from_list(Lst1),io:f......