aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_db.c
diff options
context:
space:
mode:
authorAnthony Ramine <[email protected]>2014-05-25 16:06:17 +0200
committerAnthony Ramine <[email protected]>2014-05-30 16:04:30 +0200
commit7adc2c36b0e839384baac50be35c0999d1e546df (patch)
treefb5943c386e0308509b655735d445755262e7d20 /erts/emulator/beam/erl_db.c
parente7e750a40ff875e6d62f1e7904470222ac8de269 (diff)
downloadotp-7adc2c36b0e839384baac50be35c0999d1e546df.tar.gz
otp-7adc2c36b0e839384baac50be35c0999d1e546df.tar.bz2
otp-7adc2c36b0e839384baac50be35c0999d1e546df.zip
Implement ets:take/2
This new ETS BIF returns and deletes objects from tables.
Diffstat (limited to 'erts/emulator/beam/erl_db.c')
-rw-r--r--erts/emulator/beam/erl_db.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_db.c b/erts/emulator/beam/erl_db.c
index 8f246ffa07..fba1e32230 100644
--- a/erts/emulator/beam/erl_db.c
+++ b/erts/emulator/beam/erl_db.c
@@ -753,6 +753,31 @@ BIF_RETTYPE ets_prev_2(BIF_ALIST_2)
BIF_RET(ret);
}
+/*
+** take(Tab, Key)
+*/
+BIF_RETTYPE ets_take_2(BIF_ALIST_2)
+{
+ DbTable* tb;
+#ifdef DEBUG
+ int cret;
+#endif
+ Eterm ret;
+ CHECK_TABLES();
+
+ tb = db_get_table(BIF_P, BIF_ARG_1, DB_WRITE, LCK_WRITE_REC);
+ if (!tb) {
+ BIF_ERROR(BIF_P, BADARG);
+ }
+#ifdef DEBUG
+ cret =
+#endif
+ tb->common.meth->db_take(BIF_P, tb, BIF_ARG_2, &ret);
+ ASSERT(cret == DB_ERROR_NONE);
+ db_unlock(tb, LCK_WRITE_REC);
+ BIF_RET(ret);
+}
+
/*
** update_element(Tab, Key, {Pos, Value})
** update_element(Tab, Key, [{Pos, Value}])