From: <wil...@ai...> - 2007-11-09 18:57:50
|
On Wed, Nov 07, 2007 at 01:17:51PM +0000, Nikodemus Siivola wrote: > On 06 Nov 2007 19:20:30 +0200, Juho Snellman <js...@ik...> wrote: > > "Nikodemus Siivola" <nik...@ra...> writes: > > > That attached patch adds > > > > > > * :SYNCHRONIZED keyword argument to MAKE-HASH-TABLE (defaulting to NIL), > > > which makes parallel writers safe. > > > > > > * HASH-TABLE-SYNCHRONIZED-P tells is a hash-table is actually synchronized. > > > > > > * WITH-LOCKED-HASH-TABLE uses the existing hash-table lock to provide > > > atomicity for larger blocks of code. > > > > > > Comments? > > > > Is there a reason for distinguishing between synchronization and > > locking in these names? > > Not really. Or rather, I'm not sure which one it should be. > > > Why does DOHASH acquire the lock for synchronized tables, while > > MAPHASH and WITH-HASH-TABLE iterator do not? > > Because MAPHASH and WITH-HASH-TABLE iterator are clearly subject to > the CLHS traversal requirements (no side-effects allowed except for the current > element) I did not think adding a lock around them would be necessary. > Maybe they should get locks. > > DOHASH on the other hand, we use all over the place internally, and > would have required adding WITH-LOCKED-HASH-TABLE all over the place. That seems like an OK reason to make an internal hash table iterator which is not parallel to MAPHASH. However, if DOHASH is now going to behave less like MAPHASH, I'd prefer that it look less like MAPHASH too. You could change the name to something like DOHASH-LOCKED (or something more inspired and less clumsy than that), or tweak the syntax: perhaps changing the DOHASH definition to - (defmacro dohash ((key-var value-var table &optional result) &body body) + (defmacro dohash ((key-var value-var table &key result locked) &body body) then review the existing DOHASH forms and add :RESULT and/or :LOCKED T as necessary. -- William Harold Newman <wil...@ai...> PGP key fingerprint 85 CE 1C BA 79 8D 51 8C B9 25 FB EE E0 C3 E5 7C If you can't remember what mnemonic means, you've got a problem. -- _Programming Perl_ |