[Issue 8831] New: core.atomic: add compare-and-swap function with other result type

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Oct 16 15:08:46 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8831

           Summary: core.atomic: add compare-and-swap function with other
                    result type
           Product: D
           Version: D2
          Platform: x86
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: 4denizzz at gmail.com


--- Comment #0 from mimocrocodil <4denizzz at gmail.com> 2012-10-16 15:08:40 PDT ---
Many algorithms require to know what value it was under a pointer at the time
of comparison. (This value is unknown only when compare-and-swap fails, of
course.) 
For example, it is required for RTCSS algorithm from which it can be obtained
CASN (compare-and-swap for any number of the elements).

Probably, CMPXCHG can do that.

Ideally it would be able to get value under pointer at the time of comparison
and the result of compare (true/false) as a struct. I do not know about
performance of that behaviour but in terms of more high-level programming it
will be useful. (CAS can be called often by its nature, and some of its result
will not be used usually, but I do not know, may be such cases will be
optimized by compiler.)

Or may be it can be three functions with different names.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list