| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- //
- // System.Threading.Interlocked.cs
- //
- // Author:
- // Dick Porter ([email protected])
- //
- // (C) Ximian, Inc. http://www.ximian.com
- //
- namespace System.Threading
- {
- public sealed class Interlocked
- {
- public static int CompareExchange(ref int location1, int value, int comparand) {
- // lock
- if(comparand==location1) {
- int ret;
-
- ret=location1;
- location1=value;
- return(ret);
- }
- return(location1);
- }
- public static object CompareExchange(ref object location1, object value, object comparand) {
- // lock
- if(comparand==location1) {
- object ret;
-
- ret=location1;
- location1=value;
- return(ret);
- }
- return(location1);
- }
- public static float CompareExchange(ref float location1, float value, float comparand) {
- // lock
- if(comparand==location1) {
- float ret;
-
- ret=location1;
- location1=value;
- return(ret);
- }
- return(location1);
- }
- public static int Decrement(ref int location) {
- // lock
- location--;
- return(location);
- }
- public static long Decrement(ref long location) {
- // lock
- location--;
- return(location);
- }
- public static int Exchange(ref int location1, int value) {
- // lock
- int ret;
-
- ret=location1;
- location1=value;
- return(ret);
- }
- public static object Exchange(ref object location1, object value) {
- // lock
- object ret;
-
- ret=location1;
- location1=value;
- return(ret);
- }
- public static float Exchange(ref float location1, float value) {
- // lock
- float ret;
-
- ret=location1;
- location1=value;
- return(ret);
- }
- public static int Increment(ref int location) {
- // lock
- location++;
- return(location);
- }
- public static long Increment(ref long location) {
- // lock
- location++;
- return(location);
- }
- }
- }
|