1 %%%-------------------------------------------------------------------
2 %%% File : etorrent_t_pool_sup.erl
3 %%% Author : Jesper Louis Andersen <jesper.louis.andersen@gmail.com>
4 %%% License : See COPYING
5 %%% Description : Supervisor for the pool of torrents
7 %%% Created : 13 Jul 2007 by
8 %%% Jesper Louis Andersen <jesper.louis.andersen@gmail.com>
9 %%%-------------------------------------------------------------------
10 -module(etorrent_t_pool_sup
).
12 -behaviour(supervisor
).
15 -export([start_link
/0, add_torrent
/3, stop_torrent
/1]).
17 %% Supervisor callbacks
20 -define(SERVER
, ?MODULE
).
22 %%====================================================================
24 %%====================================================================
26 supervisor:start_link({local
, ?SERVER
}, ?MODULE
, []).
28 add_torrent(File
, Local_PeerId
, Id
) ->
30 {etorrent_t_sup
, start_link
, [File
, Local_PeerId
, Id
]},
31 transient
, infinity
, supervisor
, [etorrent_t_sup
]},
32 supervisor:start_child(?SERVER
, Torrent
).
35 supervisor:terminate_child(?SERVER
, File
),
36 supervisor:delete_child(?SERVER
, File
).
38 %%====================================================================
39 %% Supervisor callbacks
40 %%====================================================================
42 {ok
,{{one_for_one
, 5, 60}, []}}.
44 %%====================================================================
46 %%====================================================================