33
33
DbTerm dbterm; /* The actual term */
36
#define DB_HASH_LOCK_CNT 16
37
typedef struct db_table_hash_fine_locks {
40
byte _cache_line_alignment[64];
41
}lck_vec[DB_HASH_LOCK_CNT];
42
} DbTableHashFineLocks;
36
44
typedef struct db_table_hash {
37
45
DbTableCommon common;
39
/* Hash-specific fields */
40
FixedDeletion *fixdel; /*
41
* List of slots where elements have
42
* been deleted while table is fixed.
44
HashDbTerm ***seg; /* The actual table */
46
/* Hash-specific fields, 32-bit quantities */
47
int szm; /* current size mask */
48
int nactive; /* Number of "active" slots */
47
erts_smp_atomic_t segtab; /* The segment table (struct segment**) */
48
erts_smp_atomic_t szm; /* current size mask. */
50
/* SMP: nslots and nsegs are protected by is_resizing or table write lock */
49
51
int nslots; /* Total number of slots */
50
int p; /* Split position */
51
int nsegs; /* Number of segments */
52
int nsegs; /* Size of segment table */
54
/* List of slots where elements have been deleted while table was fixed */
55
erts_smp_atomic_t fixdel; /* (FixedDeletion*) */
56
erts_smp_atomic_t nactive; /* Number of "active" slots */
57
erts_smp_atomic_t is_resizing; /* grow/shrink in progress */
59
DbTableHashFineLocks* locks;
55
65
** Function prototypes, looks the same (except the suffix) for all
56
66
** table types. The process is always an [in out] parameter.
58
68
void db_initialize_hash(void);
59
69
void db_unfix_table_hash(DbTableHash *tb /* [in out] */);
70
Uint db_kept_items_hash(DbTableHash *tb);
61
72
/* Interface for meta pid table */
62
73
int db_create_hash(Process *p,
63
74
DbTable *tbl /* [in out] */);
65
int db_put_hash(Process *p, DbTable *tbl, Eterm obj, Eterm *ret);
76
int db_put_hash(DbTable *tbl, Eterm obj, int key_clash_fail);
67
78
int db_get_hash(Process *p, DbTable *tbl, Eterm key, Eterm *ret);
69
int db_erase_hash(Process *p, DbTable *tbl, Eterm key, Eterm *ret);
80
int db_erase_hash(DbTable *tbl, Eterm key, Eterm *ret);
71
82
int db_get_element_array(DbTable *tbl,