Skip to content

Commit

Permalink
Adds seresye_engine:cleanup/1 that will delete engine's ETS tables
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurii Rashkovskii committed Mar 4, 2012
1 parent 2d0c7a2 commit 5d6e626
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/seresye_engine.erl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
%% External exports
%%====================================================================

-export([new/0, new/1, serialize/1, restore/1,
-export([new/0, new/1, serialize/1, restore/1, cleanup/1,
set_hooks/2, get_fired_rule/1,
add_rules/2, add_rule/2, add_rule/3, assert/2, get_kb/1,
get_rules_fired/1, get_client_state/1, set_client_state/2,
Expand All @@ -51,6 +51,10 @@ set_client_state(EngineState, NewState) ->
get_client_state(#seresye{client_state=State}) ->
State.

cleanup(#seresye{ alfa = Alfa0, join = Join0 }) ->
[ begin (catch ets:delete(Tab)), Tab end || {_, Tab, _} <- Alfa0 ] ++
[ begin (catch ets:delete(Tab)), Tab end || {{Tab, _}, _, _, _, _} <- Join0, is_integer(Tab) ].

restore(#seresye{ alfa = Alfa0, join = Join0 } = Engine) ->
TabCache = ets:new(tab_cache, []),
Alfa = [ {Cond, restore_tab(TabCache, Tab), Alfa_fun}
Expand Down

0 comments on commit 5d6e626

Please sign in to comment.