1
R16B02 erl_db.c:1272erlang ets BIF實現ets_new_2爲什麼要這樣做?
/* we create table outside any table lock
* and take the unusal cost of destroy table if it
* fails to find a slot
*/
{
DbTable init_tb;
erts_smp_atomic_init_nob(&init_tb.common.memory_size, 0);
tb = (DbTable*) erts_db_alloc(ERTS_ALC_T_DB_TABLE,
&init_tb, sizeof(DbTable));
erts_smp_atomic_init_nob(&tb->common.memory_size,
erts_smp_atomic_read_nob(&init_tb.common.memory_size));
}
我的QU。爲什麼這樣做? init_tb只是使用common.memory_size字段。爲什麼不使用int替換?