Table of Contents

Method ConditionXor

Namespace
KZDev.PerfUtils
Assembly
KZDev.PerfUtils.dll

ConditionXor(ref int, Predicate<int>, int)

A thread-safe conditional exclusive OR operation on a variable value.

public static (int originalValue, int newValue) ConditionXor(ref int location1, Predicate<int> condition, int value)

Parameters

location1 int

A variable containing the first value to perform the XOR operation on. The result is stored in this variable.

condition Predicate<int>

The condition that must be met for the operation to proceed. The delegate takes the current value of location1 as an argument.

value int

The value to be combined with the value in location1

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 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.

ConditionXor<T>(ref int, Func<int, T, bool>, T, int)

A thread-safe conditional exclusive OR operation on a variable value with the condition based on a function that takes the current value and an argument.

public static (int originalValue, int newValue) ConditionXor<T>(ref int location1, Func<int, T, bool> condition, T argument, int value)

Parameters

location1 int

A variable containing the first value to perform the XOR operation on. The result is stored in this variable.

condition Func<int, T, bool>

The condition that must be met for the operation to proceed. The delegate takes the current value of location1 as an argument.

argument T

The argument to pass to the condition function condition

value int

The value to be combined with the value in location1

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

T

The type of the argument to pass to the condition function.

Remarks

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.

ConditionXor(ref uint, Predicate<uint>, uint)

A thread-safe conditional exclusive OR operation on a variable value.

public static (uint originalValue, uint newValue) ConditionXor(ref uint location1, Predicate<uint> condition, uint value)

Parameters

location1 uint

A variable containing the first value to perform the XOR operation on. The result is stored in this variable.

condition Predicate<uint>

The condition that must be met for the operation to proceed. The delegate takes the current value of location1 as an argument.

value uint

The value to be combined with the value in location1

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 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.

ConditionXor<T>(ref uint, Func<uint, T, bool>, T, uint)

A thread-safe conditional exclusive OR operation on a variable value with the condition based on a function that takes the current value and an argument.

public static (uint originalValue, uint newValue) ConditionXor<T>(ref uint location1, Func<uint, T, bool> condition, T argument, uint value)

Parameters

location1 uint

A variable containing the first value to perform the XOR operation on. The result is stored in this variable.

condition Func<uint, T, bool>

The condition that must be met for the operation to proceed. The delegate takes the current value of location1 as an argument.

argument T

The argument to pass to the condition function condition

value uint

The value to be combined with the value in location1

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

T

The type of the argument to pass to the condition function.

Remarks

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.

ConditionXor(ref long, Predicate<long>, long)

A thread-safe conditional exclusive OR operation on a variable value.

public static (long originalValue, long newValue) ConditionXor(ref long location1, Predicate<long> condition, long value)

Parameters

location1 long

A variable containing the first value to perform the XOR operation on. The result is stored in this variable.

condition Predicate<long>

The condition that must be met for the operation to proceed. The delegate takes the current value of location1 as an argument.

value long

The value to be combined with the value in location1

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 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.

ConditionXor<T>(ref long, Func<long, T, bool>, T, long)

A thread-safe conditional exclusive OR operation on a variable value with the condition based on a function that takes the current value and an argument.

public static (long originalValue, long newValue) ConditionXor<T>(ref long location1, Func<long, T, bool> condition, T argument, long value)

Parameters

location1 long

A variable containing the first value to perform the XOR operation on. The result is stored in this variable.

condition Func<long, T, bool>

The condition that must be met for the operation to proceed. The delegate takes the current value of location1 as an argument.

argument T

The argument to pass to the condition function condition

value long

The value to be combined with the value in location1

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

T

The type of the argument to pass to the condition function.

Remarks

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.

ConditionXor(ref ulong, Predicate<ulong>, ulong)

A thread-safe conditional exclusive OR operation on a variable value.

public static (ulong originalValue, ulong newValue) ConditionXor(ref ulong location1, Predicate<ulong> condition, ulong value)

Parameters

location1 ulong

A variable containing the first value to perform the XOR operation on. The result is stored in this variable.

condition Predicate<ulong>

The condition that must be met for the operation to proceed. The delegate takes the current value of location1 as an argument.

value ulong

The value to be combined with the value in location1

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 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.

ConditionXor<T>(ref ulong, Func<ulong, T, bool>, T, ulong)

A thread-safe conditional exclusive OR operation on a variable value with the condition based on a function that takes the current value and an argument.

public static (ulong originalValue, ulong newValue) ConditionXor<T>(ref ulong location1, Func<ulong, T, bool> condition, T argument, ulong value)

Parameters

location1 ulong

A variable containing the first value to perform the XOR operation on. The result is stored in this variable.

condition Func<ulong, T, bool>

The condition that must be met for the operation to proceed. The delegate takes the current value of location1 as an argument.

argument T

The argument to pass to the condition function condition

value ulong

The value to be combined with the value in location1

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

T

The type of the argument to pass to the condition function.

Remarks

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.