Last update Fri Dec 30 22:46:40 2005
std
 std.atomic
 std.exception
 std.intrinsic
 std.thread

std.atomic



enum msync;
Memory synchronization flag. If the supplied option is not available on the current platform then a stronger method will be used instead.

hlb
hoist-load barrier

ddhlb
hoist-load barrier with data-dependency "hint"

hsb
hoist-store barrier

slb
sink-load barrier

ssb
sink-store barrier

acq
hoist-load + hoist-store barrier

rel
sink-load + sink-store barrier

none
naked

template atomicLoad(T,msync ms : cast(msync)7)
template atomicLoad(T,msync ms : cast(msync)0)
template atomicLoad(T,msync ms : cast(msync)1)
template atomicLoad(T,msync ms : cast(msync)5)
Refreshes the contents of 'val' from main memory. This operation is both lock-free and atomic.

Returns:
The loaded value.

Params:
val The value to load. This value must be properly aligned.

template atomicStore(T,msync ms : cast(msync)7)
template atomicStore(T,msync ms : cast(msync)4)
template atomicStore(T,msync ms : cast(msync)5)
template atomicStore(T,msync ms : cast(msync)6)
Stores 'newval' to the memory referenced by 'val'. This operation is both lock-free and atomic.

Params:
val The destination variable.
newval The value to store.

template atomicStoreIf(T,msync ms : cast(msync)7)
template atomicStoreIf(T,msync ms : cast(msync)4)
template atomicStoreIf(T,msync ms : cast(msync)5)
template atomicStoreIf(T,msync ms : cast(msync)6)
Stores 'newval' to the memory referenced by 'val' if val is equal to 'equalTo'. This operation is both lock-free and atomic.

Returns:
true if the store occurred, false if not.

Params:
val The destination variable.
newval The value to store.
equalTo The comparison value.

struct Atomic;
This class represents a value which will be subject to competing access. All accesses to this value will be synchronized with main memory, and various memory barriers may be employed for instruction ordering. Any primitive type of size equal to or smaller than the memory bus size is allowed, so 32-bit machines may use values with size <= int.sizeof and 64-bit machines may use values with size <= long.sizeof. The one exception to this rule is that architectures that support DCAS will allow double-wide storeIf operations. The 32-bit x86 architecture, for example, supports 64-bit storeIf operations.

template load(msync ms : msync.none)
template load(msync ms : msync.hlb)
template load(msync ms : msync.ddhlb)
template load(msync ms : msync.acq)
Refreshes the contents of this value from main memory. This operation is both lock-free and atomic.

Returns:
The loaded value.

template store(msync ms : msync.none)
template store(msync ms : msync.ssb)
template store(msync ms : msync.acq)
template store(msync ms : msync.rel)
Stores 'newval' to the memory referenced by this value. This operation is both lock-free and atomic.

Params:
newval The value to store.

template storeIf(msync ms : msync.none)
template storeIf(msync ms : msync.ssb)
template storeIf(msync ms : msync.acq)
template storeIf(msync ms : msync.rel)
Stores 'newval' to the memory referenced by this value if val is equal to 'equalTo'. This operation is both lock-free and atomic.

Returns:
true if the store occurred, false if not.

Params:
newval The value to store.
equalTo The comparison value.