« Return to Thread: Is ets:insert/2 (with multiple objects) isolated with respect to concurrent readers?

Re: Is ets:insert/2 (with multiple objects) isolated with respect to concurrent readers?

by Ulf Wiger-3 :: Rate this Message:

Reply to Author | View in Thread

Chris Newcombe wrote:
> Please could the isolation behavior be officially documented for
> ets:insert, ets:insert_new, and ets:delete_all_objects?

Granted, you're asking for official documentation, and I
agree that this is important.

Meanwhile, the implementation (R13B01) of ets:insert/2
takes a table lock if the second argument is a non-empty
list in order to ensure atomicity. Same with insert_new().

  /* Write lock table if more than one object to keep atomicy */
  kind = ((is_list(BIF_ARG_2) && CDR(list_val(BIF_ARG_2)) != NIL)
          ? LCK_WRITE : LCK_WRITE_REC);

Since write locks are exclusive (no reads allowed while a
resource is write-locked), isolation will also hold.

BR,
Ulf W
--
Ulf Wiger
CTO, Erlang Training & Consulting Ltd
http://www.erlang-consulting.com

________________________________________________________________
erlang-questions mailing list. See http://www.erlang.org/faq.html
erlang-questions (at) erlang.org

 « Return to Thread: Is ets:insert/2 (with multiple objects) isolated with respect to concurrent readers?