Method ConditionClearBits
ConditionClearBits(ref int, Predicate<int>, int)
A thread-safe method to conditionally clear a specific set of bits in a variable.
public static (int originalValue, int newValue) ConditionClearBits(ref int location1, Predicate<int> condition, int clearBitsValue)
Parameters
location1intA variable containing the bits to clear. The result is stored in this variable.
conditionPredicate<int>The condition that must be met for the operation to proceed. The delegate takes the current value of
location1as an argument.clearBitsValueintThe value that holds the bits to clear in
location1. All the bits set in this value will be cleared inlocation1.
Returns
- (int originalValue, int newValue)
A tuple containing the original value and the new value after the operation. If the condition is not met, the original value is returned in both fields.
Remarks
This method is a convenience method that is a semantic alias for
ConditionAnd(ref int, Predicate<int>, int) with the
bitwise complement of clearBitsValue
This method uses a Predicate<T> to determine if the operation
should proceed based on the current value of location1. If
condition returns true, then the XOR
result is stored in location1 if the current value is the
same as the value passed to the condition. If the value has changed in the time
between being read, and processed by condition, the operation
is repeated until either the condition is not met, or the operation is successful.
This means that if another thread changes the value of location1 between
when it is read, and when the condition is processed, the condition
could be called multiple times before the operation is successful.
ConditionClearBits<T>(ref int, Func<int, T, bool>, T, int)
A thread-safe method to conditionally clear a specific set of bits in a variable with the condition based on a function that takes the current value and an argument.
public static (int originalValue, int newValue) ConditionClearBits<T>(ref int location1, Func<int, T, bool> condition, T argument, int clearBitsValue)
Parameters
location1intA variable containing the bits to clear. The result is stored in this variable.
conditionFunc<int, T, bool>The condition that must be met for the operation to proceed. The delegate takes the current value of
location1as an argument.argumentTThe argument to pass to the condition function
conditionclearBitsValueintThe value that holds the bits to clear in
location1. All the bits set in this value will be cleared inlocation1.
Returns
- (int originalValue, int newValue)
A tuple containing the original value and the new value after the operation. If the condition is not met, the original value is returned in both fields.
Type Parameters
TThe type of the argument to pass to the condition function.
Remarks
This method is a convenience method that is a semantic alias for
ConditionAnd<T>(ref int, Func<int, T, bool>, T, int) with the
bitwise complement of clearBitsValue
This method uses a Func<T1, T2, TResult> to determine if the operation
should proceed based on the current value of location1. If
condition returns true, then the XOR
result is stored in location1 if the current value is the
same as the value passed to the condition. If the value has changed in the time
between being read, and processed by condition, the operation
is repeated until either the condition is not met, or the operation is successful.
This means that if another thread changes the value of location1 between
when it is read, and when the condition is processed, the condition
could be called multiple times before the operation is successful.
ConditionClearBits(ref uint, Predicate<uint>, uint)
A thread-safe method to conditionally clear a specific set of bits in a variable.
public static (uint originalValue, uint newValue) ConditionClearBits(ref uint location1, Predicate<uint> condition, uint clearBitsValue)
Parameters
location1uintA variable containing the bits to clear. The result is stored in this variable.
conditionPredicate<uint>The condition that must be met for the operation to proceed. The delegate takes the current value of
location1as an argument.clearBitsValueuintThe value that holds the bits to clear in
location1. All the bits set in this value will be cleared inlocation1.
Returns
- (uint originalValue, uint newValue)
A tuple containing the original value and the new value after the operation. If the condition is not met, the original value is returned in both fields.
Remarks
This method is a convenience method that is a semantic alias for
ConditionAnd(ref uint, Predicate<uint>, uint) with the
bitwise complement of clearBitsValue
This method uses a Predicate<T> to determine if the operation
should proceed based on the current value of location1. If
condition returns true, then the XOR
result is stored in location1 if the current value is the
same as the value passed to the condition. If the value has changed in the time
between being read, and processed by condition, the operation
is repeated until either the condition is not met, or the operation is successful.
This means that if another thread changes the value of location1 between
when it is read, and when the condition is processed, the condition
could be called multiple times before the operation is successful.
ConditionClearBits<T>(ref uint, Func<uint, T, bool>, T, uint)
A thread-safe method to conditionally clear a specific set of bits in a variable with the condition based on a function that takes the current value and an argument.
public static (uint originalValue, uint newValue) ConditionClearBits<T>(ref uint location1, Func<uint, T, bool> condition, T argument, uint clearBitsValue)
Parameters
location1uintA variable containing the bits to clear. The result is stored in this variable.
conditionFunc<uint, T, bool>The condition that must be met for the operation to proceed. The delegate takes the current value of
location1as an argument.argumentTThe argument to pass to the condition function
conditionclearBitsValueuintThe value that holds the bits to clear in
location1. All the bits set in this value will be cleared inlocation1.
Returns
- (uint originalValue, uint newValue)
A tuple containing the original value and the new value after the operation. If the condition is not met, the original value is returned in both fields.
Type Parameters
TThe type of the argument to pass to the condition function.
Remarks
This method is a convenience method that is a semantic alias for
ConditionAnd<T>(ref uint, Func<uint, T, bool>, T, uint) with the
bitwise complement of clearBitsValue
This method uses a Func<T1, T2, TResult> to determine if the operation
should proceed based on the current value of location1. If
condition returns true, then the XOR
result is stored in location1 if the current value is the
same as the value passed to the condition. If the value has changed in the time
between being read, and processed by condition, the operation
is repeated until either the condition is not met, or the operation is successful.
This means that if another thread changes the value of location1 between
when it is read, and when the condition is processed, the condition
could be called multiple times before the operation is successful.
ConditionClearBits(ref long, Predicate<long>, long)
A thread-safe method to conditionally clear a specific set of bits in a variable.
public static (long originalValue, long newValue) ConditionClearBits(ref long location1, Predicate<long> condition, long clearBitsValue)
Parameters
location1longA variable containing the bits to clear. The result is stored in this variable.
conditionPredicate<long>The condition that must be met for the operation to proceed. The delegate takes the current value of
location1as an argument.clearBitsValuelongThe value that holds the bits to clear in
location1. All the bits set in this value will be cleared inlocation1.
Returns
- (long originalValue, long newValue)
A tuple containing the original value and the new value after the operation. If the condition is not met, the original value is returned in both fields.
Remarks
This method is a convenience method that is a semantic alias for
ConditionAnd(ref long, Predicate<long>, long) with the
bitwise complement of clearBitsValue
This method uses a Predicate<T> to determine if the operation
should proceed based on the current value of location1. If
condition returns true, then the XOR
result is stored in location1 if the current value is the
same as the value passed to the condition. If the value has changed in the time
between being read, and processed by condition, the operation
is repeated until either the condition is not met, or the operation is successful.
This means that if another thread changes the value of location1 between
when it is read, and when the condition is processed, the condition
could be called multiple times before the operation is successful.
ConditionClearBits<T>(ref long, Func<long, T, bool>, T, long)
A thread-safe method to conditionally clear a specific set of bits in a variable with the condition based on a function that takes the current value and an argument.
public static (long originalValue, long newValue) ConditionClearBits<T>(ref long location1, Func<long, T, bool> condition, T argument, long clearBitsValue)
Parameters
location1longA variable containing the bits to clear. The result is stored in this variable.
conditionFunc<long, T, bool>The condition that must be met for the operation to proceed. The delegate takes the current value of
location1as an argument.argumentTThe argument to pass to the condition function
conditionclearBitsValuelongThe value that holds the bits to clear in
location1. All the bits set in this value will be cleared inlocation1.
Returns
- (long originalValue, long newValue)
A tuple containing the original value and the new value after the operation. If the condition is not met, the original value is returned in both fields.
Type Parameters
TThe type of the argument to pass to the condition function.
Remarks
This method is a convenience method that is a semantic alias for
ConditionAnd<T>(ref long, Func<long, T, bool>, T, long) with the
bitwise complement of clearBitsValue
This method uses a Func<T1, T2, TResult> to determine if the operation
should proceed based on the current value of location1. If
condition returns true, then the XOR
result is stored in location1 if the current value is the
same as the value passed to the condition. If the value has changed in the time
between being read, and processed by condition, the operation
is repeated until either the condition is not met, or the operation is successful.
This means that if another thread changes the value of location1 between
when it is read, and when the condition is processed, the condition
could be called multiple times before the operation is successful.
ConditionClearBits(ref ulong, Predicate<ulong>, ulong)
A thread-safe method to conditionally clear a specific set of bits in a variable.
public static (ulong originalValue, ulong newValue) ConditionClearBits(ref ulong location1, Predicate<ulong> condition, ulong clearBitsValue)
Parameters
location1ulongA variable containing the bits to clear. The result is stored in this variable.
conditionPredicate<ulong>The condition that must be met for the operation to proceed. The delegate takes the current value of
location1as an argument.clearBitsValueulongThe value that holds the bits to clear in
location1. All the bits set in this value will be cleared inlocation1.
Returns
- (ulong originalValue, ulong newValue)
A tuple containing the original value and the new value after the operation. If the condition is not met, the original value is returned in both fields.
Remarks
This method is a convenience method that is a semantic alias for
ConditionAnd(ref ulong, Predicate<ulong>, ulong) with the
bitwise complement of clearBitsValue
This method uses a Predicate<T> to determine if the operation
should proceed based on the current value of location1. If
condition returns true, then the XOR
result is stored in location1 if the current value is the
same as the value passed to the condition. If the value has changed in the time
between being read, and processed by condition, the operation
is repeated until either the condition is not met, or the operation is successful.
This means that if another thread changes the value of location1 between
when it is read, and when the condition is processed, the condition
could be called multiple times before the operation is successful.
ConditionClearBits<T>(ref ulong, Func<ulong, T, bool>, T, ulong)
A thread-safe method to conditionally clear a specific set of bits in a variable with the condition based on a function that takes the current value and an argument.
public static (ulong originalValue, ulong newValue) ConditionClearBits<T>(ref ulong location1, Func<ulong, T, bool> condition, T argument, ulong clearBitsValue)
Parameters
location1ulongA variable containing the bits to clear. The result is stored in this variable.
conditionFunc<ulong, T, bool>The condition that must be met for the operation to proceed. The delegate takes the current value of
location1as an argument.argumentTThe argument to pass to the condition function
conditionclearBitsValueulongThe value that holds the bits to clear in
location1. All the bits set in this value will be cleared inlocation1.
Returns
- (ulong originalValue, ulong newValue)
A tuple containing the original value and the new value after the operation. If the condition is not met, the original value is returned in both fields.
Type Parameters
TThe type of the argument to pass to the condition function.
Remarks
This method is a convenience method that is a semantic alias for
ConditionAnd<T>(ref ulong, Func<ulong, T, bool>, T, ulong) with the
bitwise complement of clearBitsValue
This method uses a Func<T1, T2, TResult> to determine if the operation
should proceed based on the current value of location1. If
condition returns true, then the XOR
result is stored in location1 if the current value is the
same as the value passed to the condition. If the value has changed in the time
between being read, and processed by condition, the operation
is repeated until either the condition is not met, or the operation is successful.
This means that if another thread changes the value of location1 between
when it is read, and when the condition is processed, the condition
could be called multiple times before the operation is successful.