Re: Hash table thread safety
Martin Simmons <[email protected]> Wed, 1 Apr 2026 19:59:55 +0100
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <[email protected]> |
>>>>> On Tue, 31 Mar 2026 12:15:18 +0100, Tim Bradshaw said: > > The new one keeps a natural number which is the next index, and then two > hash tables: k->o, and o->v (actually to a cons of key and value), where o > is an index. If you can increment the next index slot atomically (which you > can in LW and SBCL) then you can know you have a unique (up to machine > integers wrapping on SBCL) index for insertion. The problems are (a) > slower, and (b) if you delete lots of entries you end up with holes in the > index space, so iteration can be slow. You can get orphan o->kv entries but > it can GC those if asked. Can you replace the two hash tables with a single hash table mapping the key to a cons of the index and the value? -- Martin Simmons LispWorks Ltd http://www.lispworks.com/ _______________________________________________ Lisp Hug - the mailing list for LispWorks users [email protected] http://www.lispworks.com/support/lisp-hug.html