Welcome! Please see the About page for a little more info on how this works.

+1 vote
in Records and Types by
recategorized by

As a person who is really into atoms and compare and set as a concurrency primitive, it would be nice to be able to do a compare and set on mutable fields in a deftype without incurring the overhead (more objects taking more memory, and more pointers to chase) of either a java AtomicReference or a clojure atom.

The jvm has several mechanisms that allow you to directly cas on a field (AtomicReferenceFieldUpdater , VarHandles. maybe others). It seems like deftype could make such a thing available on request.

It is currently possible to use AtomicReferenceFieldUpdater with deftype, but is somewhat convoluted due to volatile fields being private, and the lack of static initializers.

Please log in or register to answer this question.