aboutsummaryrefslogtreecommitdiffstats
path: root/lib/asn1/src/asn1ct_table.erl
diff options
context:
space:
mode:
authorAdam Lindberg <[email protected]>2012-01-12 15:42:21 +0100
committerAdam Lindberg <[email protected]>2012-02-28 14:59:32 +0100
commitaa4e27ebac9eb287069fab859fe5dcdab82c75bf (patch)
tree7303d7d5f04c888a7934b783937ac2e3dc7f978a /lib/asn1/src/asn1ct_table.erl
parent93f0641c2122d6c23e2ac5f18579ef879599fc16 (diff)
downloadotp-aa4e27ebac9eb287069fab859fe5dcdab82c75bf.tar.gz
otp-aa4e27ebac9eb287069fab859fe5dcdab82c75bf.tar.bz2
otp-aa4e27ebac9eb287069fab859fe5dcdab82c75bf.zip
[asn1] Make tables and processes unnamed
- Refactor and clean up asn1_db process - Remove unused stop function in asn1ct.erl - Remove infinite loop possibilites in asn1ct_check.erl - test/1,2,3 now run in separate process - Update documentation for new test options
Diffstat (limited to 'lib/asn1/src/asn1ct_table.erl')
-rw-r--r--lib/asn1/src/asn1ct_table.erl40
1 files changed, 26 insertions, 14 deletions
diff --git a/lib/asn1/src/asn1ct_table.erl b/lib/asn1/src/asn1ct_table.erl
index b7ae1d7105..a5eb6d0413 100644
--- a/lib/asn1/src/asn1ct_table.erl
+++ b/lib/asn1/src/asn1ct_table.erl
@@ -21,7 +21,9 @@
%% Table abstraction module for ASN.1 compiler
+-export([new/1]).
-export([new/2]).
+-export([new_reuse/1]).
-export([new_reuse/2]).
-export([exists/1]).
-export([size/1]).
@@ -33,32 +35,42 @@
%% Always creates a new table
+new(Table) -> new(Table, []).
new(Table, Options) ->
- case ets:info(Table) of
- undefined ->
- ets:new(Table, Options);
- _ ->
- delete(Table),
- ets:new(Table, Options)
- end.
+ TableId = case get(Table) of
+ undefined ->
+ ets:new(Table, Options);
+ _ ->
+ delete(Table),
+ ets:new(Table, Options)
+ end,
+ put(Table, TableId).
+%% Only create it if it doesn't exist yet
+new_reuse(Table) -> new_reuse(Table, []).
new_reuse(Table, Options) ->
not exists(Table) andalso new(Table, Options).
-exists(Table) -> ets:info(Table) =/= undefined.
+exists(Table) -> get(Table) =/= undefined.
-size(Table) -> ets:info(Table, size).
+size(Table) -> ets:info(get(Table), size).
-insert(Table, Tuple) -> ets:insert(Table, Tuple).
+insert(Table, Tuple) -> ets:insert(get(Table), Tuple).
-lookup(Table, Key) -> ets:lookup(Table, Key).
+lookup(Table, Key) -> ets:lookup(get(Table), Key).
-match(Table, MatchSpec) -> ets:match(Table, MatchSpec).
+match(Table, MatchSpec) -> ets:match(get(Table), MatchSpec).
-to_list(Table) -> ets:tab2list(Table).
+to_list(Table) -> ets:tab2list(get(Table)).
delete(Tables) when is_list(Tables) ->
[delete(T) || T <- Tables],
true;
delete(Table) when is_atom(Table) ->
- exists(Table) andalso ets:delete(Table).
+ case get(Table) of
+ undefined ->
+ true;
+ TableId ->
+ ets:delete(TableId),
+ erase(Table)
+ end.