Permalink
Browse files

update kilim jar w/new fix; implement ets:delete_all_objects

  • Loading branch information...
1 parent 9060362 commit 9b1be7c555c3cc0cbb2e834e9833d95485c3a9a8 @krestenkrab krestenkrab committed Dec 21, 2009
View
Binary file not shown.
@@ -62,6 +62,7 @@
protected final EAtom aname;
protected final boolean is_named;
protected final EAtom type;
+ protected final APersistentMap empty;
private Ref mapRef;
ETable(EProc owner, EAtom type, EInteger tid, EAtom aname, EAtom access, int keypos,
@@ -80,7 +81,7 @@
} catch (Exception e) {
throw new ErlangError(am_stm);
}
-
+ empty = map;
owner.add_exit_hook(this);
}
@@ -222,4 +223,15 @@ protected void set(IPersistentMap map) {
protected abstract EInteger select_delete(EMatchSpec matcher);
+ protected void delete_all_objects() {
+ in_tx(new WithMap<Object>() {
+
+ @Override
+ protected Object run(IPersistentMap map) {
+ set(empty);
+ return null;
+ }
+ });
+ }
+
}
@@ -224,4 +224,17 @@ protected Integer run(IPersistentMap map) {
return ERT.box(delete_count);
}
+ protected void delete_all_objects() {
+ in_tx(new WithMap<Object>() {
+
+ @Override
+ protected Object run(IPersistentMap map) {
+ set(empty);
+ sizeRef.set(new Integer(0));
+ return null;
+ }
+ });
+ }
+
+
}
@@ -293,13 +293,18 @@ public static EAtom delete(EProc caller, EObject nameOrTid)
@BIF static EInteger select_delete(EProc caller, EObject nameOrTid, EObject spec)
{
ESeq lspec = spec.testSeq();
- ETable table = resolve(caller, nameOrTid, false);
+ ETable table = resolve(caller, nameOrTid, true);
if (lspec == null || table == null) throw ERT.badarg(nameOrTid, spec);
EMatchSpec matcher = EMatchSpec.compile(lspec);
return table.select_delete(matcher);
}
-
+ @BIF static EAtom delete_all_objects(EProc caller, EObject nameOrTid) {
+ ETable table = resolve(caller, nameOrTid, true);
+ if (table == null) throw ERT.badarg(nameOrTid);
+ table.delete_all_objects();
+ return ERT.TRUE;
+ }
}

0 comments on commit 9b1be7c

Please sign in to comment.