问题描述
- 有大师帮我分析下这个类的作用吗?System.Runtime.Caching.SafeBitVector32
-
有大师帮忙分析下这个类吗?我看出是一个索引,但是具体功能和作用还是没有完全吃透,有人能帮帮忙吗?internal struct SafeBitVector32 { private volatile int _data; internal bool this[int bit] { get { int data = this._data; return (data & bit) == bit; } set { int data; int num; do { data = this._data; int value2; if (value) { value2 = (data | bit); } else { value2 = (data & ~bit); } num = Interlocked.CompareExchange(ref this._data, value2, data); } while (num != data); } } internal bool ChangeValue(int bit, bool value) { while (true) { int data = this._data; int num; if (value) { num = (data | bit); } else { num = (data & ~bit); } if (data == num) { break; } int num2 = Interlocked.CompareExchange(ref this._data, num, data); if (num2 == data) { return true; } } return false; } }
}
时间: 2024-12-04 19:42:28