Mercurial > projects > qtd
comparison qt/qtd/Atomic.d @ 325:b460cd08041f signals
dmd 2.037 opEquals bug-feature
author | eldar1@eldar1-laptop |
---|---|
date | Wed, 30 Dec 2009 11:25:07 +0000 |
parents | 0d2094800bdb |
children |
comparison
equal
deleted
inserted
replaced
324:0cc996b7a601 | 325:b460cd08041f |
---|---|
114 * val = The value to load. This value must be properly aligned. | 114 * val = The value to load. This value must be properly aligned. |
115 * | 115 * |
116 * Returns: | 116 * Returns: |
117 * The loaded value. | 117 * The loaded value. |
118 */ | 118 */ |
119 T atomicLoad( inout T val ) | 119 T atomicLoad( ref T val ) |
120 { | 120 { |
121 return val; | 121 return val; |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
144 * | 144 * |
145 * Params: | 145 * Params: |
146 * val = The destination variable. | 146 * val = The destination variable. |
147 * newval = The value to store. | 147 * newval = The value to store. |
148 */ | 148 */ |
149 void atomicStore( inout T val, T newval ) | 149 void atomicStore( ref T val, T newval ) |
150 { | 150 { |
151 | 151 |
152 } | 152 } |
153 } | 153 } |
154 | 154 |
178 * equalTo = The comparison value. | 178 * equalTo = The comparison value. |
179 * | 179 * |
180 * Returns: | 180 * Returns: |
181 * true if the store occurred, false if not. | 181 * true if the store occurred, false if not. |
182 */ | 182 */ |
183 bool atomicStoreIf( inout T val, T newval, T equalTo ) | 183 bool atomicStoreIf( ref T val, T newval, T equalTo ) |
184 { | 184 { |
185 return false; | 185 return false; |
186 } | 186 } |
187 } | 187 } |
188 | 188 |
218 * The result of an atomicLoad of val immediately following the | 218 * The result of an atomicLoad of val immediately following the |
219 * increment operation. This value is not required to be equal to the | 219 * increment operation. This value is not required to be equal to the |
220 * newly stored value. Thus, competing writes are allowed to occur | 220 * newly stored value. Thus, competing writes are allowed to occur |
221 * between the increment and successive load operation. | 221 * between the increment and successive load operation. |
222 */ | 222 */ |
223 T atomicIncrement( inout T val ) | 223 T atomicIncrement( ref T val ) |
224 { | 224 { |
225 return val; | 225 return val; |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
258 * The result of an atomicLoad of val immediately following the | 258 * The result of an atomicLoad of val immediately following the |
259 * increment operation. This value is not required to be equal to the | 259 * increment operation. This value is not required to be equal to the |
260 * newly stored value. Thus, competing writes are allowed to occur | 260 * newly stored value. Thus, competing writes are allowed to occur |
261 * between the increment and successive load operation. | 261 * between the increment and successive load operation. |
262 */ | 262 */ |
263 T atomicDecrement( inout T val ) | 263 T atomicDecrement( ref T val ) |
264 { | 264 { |
265 return val; | 265 return val; |
266 } | 266 } |
267 } | 267 } |
268 } | 268 } |
521 //////////////////////////////////////////////////////////////////////////// | 521 //////////////////////////////////////////////////////////////////////////// |
522 | 522 |
523 | 523 |
524 template atomicLoad( msync ms = msync.seq, T ) | 524 template atomicLoad( msync ms = msync.seq, T ) |
525 { | 525 { |
526 T atomicLoad( inout T val ) | 526 T atomicLoad( ref T val ) |
527 in | 527 in |
528 { | 528 { |
529 assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); | 529 assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); |
530 } | 530 } |
531 body | 531 body |
668 //////////////////////////////////////////////////////////////////////////// | 668 //////////////////////////////////////////////////////////////////////////// |
669 | 669 |
670 | 670 |
671 template atomicStore( msync ms = msync.seq, T ) | 671 template atomicStore( msync ms = msync.seq, T ) |
672 { | 672 { |
673 void atomicStore( inout T val, T newval ) | 673 void atomicStore( ref T val, T newval ) |
674 in | 674 in |
675 { | 675 { |
676 assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); | 676 assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); |
677 } | 677 } |
678 body | 678 body |
822 //////////////////////////////////////////////////////////////////////////// | 822 //////////////////////////////////////////////////////////////////////////// |
823 | 823 |
824 | 824 |
825 template atomicStoreIf( msync ms = msync.seq, T ) | 825 template atomicStoreIf( msync ms = msync.seq, T ) |
826 { | 826 { |
827 bool atomicStoreIf( inout T val, T newval, T equalTo ) | 827 bool atomicStoreIf( ref T val, T newval, T equalTo ) |
828 in | 828 in |
829 { | 829 { |
830 // NOTE: 32 bit x86 systems support 8 byte CAS, which only requires | 830 // NOTE: 32 bit x86 systems support 8 byte CAS, which only requires |
831 // 4 byte alignment, so use size_t as the align type here. | 831 // 4 byte alignment, so use size_t as the align type here. |
832 static if( T.sizeof > size_t.sizeof ) | 832 static if( T.sizeof > size_t.sizeof ) |
968 // NOTE: This operation is only valid for integer or pointer types | 968 // NOTE: This operation is only valid for integer or pointer types |
969 // | 969 // |
970 static assert( isValidNumericType!(T) ); | 970 static assert( isValidNumericType!(T) ); |
971 | 971 |
972 | 972 |
973 T atomicIncrement( inout T val ) | 973 T atomicIncrement( ref T val ) |
974 in | 974 in |
975 { | 975 { |
976 assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); | 976 assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); |
977 } | 977 } |
978 body | 978 body |
1080 // NOTE: This operation is only valid for integer or pointer types | 1080 // NOTE: This operation is only valid for integer or pointer types |
1081 // | 1081 // |
1082 static assert( isValidNumericType!(T) ); | 1082 static assert( isValidNumericType!(T) ); |
1083 | 1083 |
1084 | 1084 |
1085 T atomicDecrement( inout T val ) | 1085 T atomicDecrement( ref T val ) |
1086 in | 1086 in |
1087 { | 1087 { |
1088 assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); | 1088 assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); |
1089 } | 1089 } |
1090 body | 1090 body |
1226 //////////////////////////////////////////////////////////////////////////// | 1226 //////////////////////////////////////////////////////////////////////////// |
1227 | 1227 |
1228 | 1228 |
1229 template atomicLoad( msync ms = msync.seq, T ) | 1229 template atomicLoad( msync ms = msync.seq, T ) |
1230 { | 1230 { |
1231 T atomicLoad( inout T val ) | 1231 T atomicLoad( ref T val ) |
1232 in | 1232 in |
1233 { | 1233 { |
1234 assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); | 1234 assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); |
1235 } | 1235 } |
1236 body | 1236 body |
1276 //////////////////////////////////////////////////////////////////////////// | 1276 //////////////////////////////////////////////////////////////////////////// |
1277 | 1277 |
1278 | 1278 |
1279 template atomicStore( msync ms = msync.seq, T ) | 1279 template atomicStore( msync ms = msync.seq, T ) |
1280 { | 1280 { |
1281 void atomicStore( inout T val, T newval ) | 1281 void atomicStore( ref T val, T newval ) |
1282 in | 1282 in |
1283 { | 1283 { |
1284 assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); | 1284 assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); |
1285 } | 1285 } |
1286 body | 1286 body |
1326 //////////////////////////////////////////////////////////////////////////// | 1326 //////////////////////////////////////////////////////////////////////////// |
1327 | 1327 |
1328 | 1328 |
1329 template atomicStoreIf( msync ms = msync.seq, T ) | 1329 template atomicStoreIf( msync ms = msync.seq, T ) |
1330 { | 1330 { |
1331 bool atomicStoreIf( inout T val, T newval, T equalTo ) | 1331 bool atomicStoreIf( ref T val, T newval, T equalTo ) |
1332 in | 1332 in |
1333 { | 1333 { |
1334 assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); | 1334 assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); |
1335 } | 1335 } |
1336 body | 1336 body |
1377 // NOTE: This operation is only valid for integer or pointer types | 1377 // NOTE: This operation is only valid for integer or pointer types |
1378 // | 1378 // |
1379 static assert( isValidNumericType!(T) ); | 1379 static assert( isValidNumericType!(T) ); |
1380 | 1380 |
1381 | 1381 |
1382 T atomicIncrement( inout T val ) | 1382 T atomicIncrement( ref T val ) |
1383 in | 1383 in |
1384 { | 1384 { |
1385 assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); | 1385 assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); |
1386 } | 1386 } |
1387 body | 1387 body |
1423 // NOTE: This operation is only valid for integer or pointer types | 1423 // NOTE: This operation is only valid for integer or pointer types |
1424 // | 1424 // |
1425 static assert( isValidNumericType!(T) ); | 1425 static assert( isValidNumericType!(T) ); |
1426 | 1426 |
1427 | 1427 |
1428 T atomicDecrement( inout T val ) | 1428 T atomicDecrement( ref T val ) |
1429 in | 1429 in |
1430 { | 1430 { |
1431 assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); | 1431 assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); |
1432 } | 1432 } |
1433 body | 1433 body |