8.2 編寫健壯的應用程式-健壯的服務程序
阿新 • • 發佈:2018-12-31
free(Free, Allocated, From, R) -> case lists:member({R, From}, Allocated) of true -> From ! {resource_alloc, yes}, Allocated1 = lists:delete({R, From}, Allocated), case lists:keysearch(From, 2, Allocated1) of false -> unlink(From); _ -> true end, server([R|Free], Allocated1); false -> From ! {resource_alloc, error}, server(Free, Allocated) end.