MCAS is a Common Lisp Multiple CAS library on CAR/CDR of ref-cells. An N-way MCAS, without contention, needs only N+1 CAS instructions.
This library was ported from the mcas file in David McClain's Lisp-Actors library, https://github.com/dbmcclain/Lisp-Actors/blob/main/data-objects/mcas-v4.lisp
The APIs are quite simple, only expert mcas-ref, make-mcas-ref, mcas, and mcas-val.
A structure which is designed for mcas.
Create an mcas-ref instance which can be mcased, the values will be compared by eq
.
Return T if mcas succeeded, or NIl if it failed. TRIPLES: a sequence of (ref old new) as would be suitable for CAS. But each ref must be a total-order MCAS-REF.
Get the current value of an mcas-ref.
The basis usage of mcas is very like that of normal cas, except mcas' arguments are triples.
(let* ((a (make-mcas-ref 15))
(b (make-mcas-ref 16)))
(mcas a 15 32
b 16 33)
(list (mcas-val a) (mcas-val b)))
The limitation of this library is that the mcas-places are restricted to mcas-ref structure. And the normal cas-places can be car of a list, slot of a struct, svref of a simple-array, etc, although they depend on the CL implementation.
The vanilla mcas can be used only in Lispworks, this mcas library depends on Shinmera's atomics library, which decides the potability of this library. https://github.com/Shinmera/atomics
The vanilla Lisp-Actors is shared with licence "Unlicense License". This licence claims that anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
The version of this library will keep up with that of Lisp-Actors.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。