AtomicExchange文档给出了该方法的签名:
function AtomicExchange(var Target; Value: <Integer or NativeInt or Pointer>): Integer; overload;
function AtomicExchange(var Target; Value: <Integer or NativeInt or Pointer>): Int64; overload;
function AtomicExchange(var Target; Value: <Integer or NativeInt or Pointer>): Pointer; overload;
function AtomicExchange(var Target; Value: <Integer or NativeInt or Pointer>): NativeInt; overload;
但实际上,Int64
似乎也是一个有效的参数,如下所示:
function AtomicExchange(var Target; Value: <Integer or Int64 or NativeInt or Pointer>): Integer; overload;
function AtomicExchange(var Target; Value: <Integer or Int64 or NativeInt or Pointer>): Int64; overload;
function AtomicExchange(var Target; Value: <Integer or Int64 or NativeInt or Pointer>): Pointer; overload;
function AtomicExchange(var Target; Value: <Integer or Int64 or NativeInt or Pointer>): NativeInt; overload;
注意: 除了文档之外,IDE 工具提示还建议 Int64
不是有效的参数:
实际上,我们可以使用一个 Int64
参数调用 AtomicExchange
吗?对于 32 位和 64 位目标,这能够正常工作吗?