From 04f55eb3c925705da28b3509b2f7e6b203632391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 15 Sep 2011 23:13:27 +0200 Subject: Allow websocket handlers to hibernate from the websocket_init/3 function Also improve the documentation about hibernate. --- src/cowboy_http_websocket_handler.erl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/cowboy_http_websocket_handler.erl') diff --git a/src/cowboy_http_websocket_handler.erl b/src/cowboy_http_websocket_handler.erl index 90cf7ac..2ea0a46 100644 --- a/src/cowboy_http_websocket_handler.erl +++ b/src/cowboy_http_websocket_handler.erl @@ -29,8 +29,7 @@ %% here. %% %% websocket_handle/3 receives the data from the socket. It can reply -%% something, do nothing or close the connection. You can choose to hibernate -%% the process by returning hibernate to save memory and CPU. +%% something, do nothing or close the connection. %% %% websocket_info/3 receives messages sent to the process. It has %% the same reply format as websocket_handle/3 described above. Note @@ -41,6 +40,11 @@ %% websocket_terminate/3 is meant for cleaning up. It also receives %% the request and the state previously defined, along with a reason for %% termination. +%% +%% All of websocket_init/3, websocket_handle/3 and +%% websocket_info/3 can decide to hibernate the process by adding +%% an extra element to the returned tuple, containing the atom +%% hibernate. Doing so helps save memory and improve CPU usage. -module(cowboy_http_websocket_handler). -export([behaviour_info/1]). -- cgit v1.2.3