Parallel processing Erlang接收后

Parallel processing Erlang接收后,parallel-processing,erlang,timeout,wait,Parallel Processing,Erlang,Timeout,Wait,我在Erlang中使用receive函数后遇到了一些问题,我已经在Google上搜索了一段时间,并对此进行了猛烈的攻击,但似乎无法找到答案,需要一些帮助。我有一个进程,它运行以下进程并等待消息 % Waits for messages, and puts them into the list. % If the list has the same length as the Length variable % which is the original provided list, then

我在Erlang中使用receive函数后遇到了一些问题,我已经在Google上搜索了一段时间,并对此进行了猛烈的攻击,但似乎无法找到答案,需要一些帮助。我有一个进程,它运行以下进程并等待消息

% Waits for messages, and puts them into the list. 
% If the list has the same length as the Length variable 
% which is the original provided list, then it means we are done
% and can print the results.
% If the MaxTime has passed it should just print the provided list.
wait_max_time(List, Length, MaxTime) ->
io:format("I am ~p and waiting...~n", [self()]),
receive
    X -> 
        Results = List ++ [X],
        case length(Results) =:= Length of
            true -> 
                io:format("~p~n", [Results]),
                exit(self());
            false -> 
                wait(Results, Length)
        end
after MaxTime -> io:format("List is ~p~n", [List])
end.
以上的一切似乎都很好,它总是计算,我已经用打印声明证实了这一点


但是对于耗时太长的计算,我只想打印它得到的列表,而不是继续。但是在我的代码中从未运行过之后,我做错了什么?

正如Dogbert在评论中指出的那样,我完全没有注意到我忘记在false下更改一个函数的名称,该函数调用了另一个没有超时的函数


问题解决了,谢谢。

正如Dogbert在评论中指出的那样,我完全没有注意到我忘记在false下更改一个函数的名称,该函数调用了另一个没有超时的函数


问题解决了,谢谢。

你是不是想在
false->…
中调用
wait\u max\u time
而不是
wait
?附带问题:中的#1规则是永远不要附加到列表的末尾。对于非常短的列表也可以,但是您应该养成像
[X | List]
这样构建列表的习惯,而不是
List++[X]
。您给出的代码并没有真正说明问题所在。一个好的回答会让你得到一个好的答案。这可能是因为你在慢慢地向这个过程发送信息,从而使自己的行动变得缓慢。请注意,之后的
超时在每次收到消息时都会重置。您的意思是在
false->…
中调用
wait\u max\u time
而不是
wait
?附带问题:中的#1规则是永远不会追加到列表的末尾。对于非常短的列表也可以,但是您应该养成像
[X | List]
这样构建列表的习惯,而不是
List++[X]
。您给出的代码并没有真正说明问题所在。一个好的回答会让你得到一个好的答案。这可能是因为你在慢慢地向这个过程发送信息,从而使自己的行动变得缓慢。请注意,每次收到消息时,
之后的
超时都会重置。