Skip to content

Commit

Permalink
Add InterlockedReference<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
rdeago committed Jan 22, 2024
1 parent 19b2176 commit 125cea6
Show file tree
Hide file tree
Showing 9 changed files with 236 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Two new boolean properties in `AsyncHostedService` lets subclasses decide whether `StartAsync` should fail when the service is stopped before starting (`FailOnSetupNotStarted`) or `SetupAsync` completes with `false` (`FailOnSetupUnsuccessful`).
The default value is `true` for both properties.
- Struct `Louis.Threading.InterlockedFlag` now implements `IEquatable<bool>`, as well as equality and inequality operators with `bool`.
- New struct `Louis.Threading.InterlockedReference<T>` encapsulates an object reference, so that it is always accessed in a thread-safe fashion.

### Changes to existing features

Expand Down
17 changes: 17 additions & 0 deletions src/Louis/PublicAPI/net462/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,24 @@ Louis.Threading.AsyncServiceSetupResult.NotStarted = 1 -> Louis.Threading.AsyncS
Louis.Threading.AsyncServiceSetupResult.Successful = 0 -> Louis.Threading.AsyncServiceSetupResult
Louis.Threading.AsyncServiceSetupResult.Unsuccessful = 2 -> Louis.Threading.AsyncServiceSetupResult
Louis.Threading.InterlockedFlag.Equals(bool other) -> bool
Louis.Threading.InterlockedReference<T>
Louis.Threading.InterlockedReference<T>.CompareExchange(T? value, T? comparand) -> T?
Louis.Threading.InterlockedReference<T>.Equals(Louis.Threading.InterlockedReference<T!> other) -> bool
Louis.Threading.InterlockedReference<T>.Equals(T? other) -> bool
Louis.Threading.InterlockedReference<T>.Exchange(T? value) -> T?
Louis.Threading.InterlockedReference<T>.InterlockedReference() -> void
Louis.Threading.InterlockedReference<T>.InterlockedReference(T? value) -> void
Louis.Threading.InterlockedReference<T>.IsNull.get -> bool
Louis.Threading.InterlockedReference<T>.Value.get -> T?
Louis.Threading.InterlockedReference<T>.Value.set -> void
override Louis.Threading.InterlockedReference<T>.Equals(object? obj) -> bool
override Louis.Threading.InterlockedReference<T>.GetHashCode() -> int
override Louis.Threading.InterlockedReference<T>.ToString() -> string!
static Louis.Threading.InterlockedFlag.operator !=(Louis.Threading.InterlockedFlag a, bool b) -> bool
static Louis.Threading.InterlockedFlag.operator ==(Louis.Threading.InterlockedFlag a, bool b) -> bool
static Louis.Threading.InterlockedReference<T>.operator !=(Louis.Threading.InterlockedReference<T!> a, Louis.Threading.InterlockedReference<T!> b) -> bool
static Louis.Threading.InterlockedReference<T>.operator !=(Louis.Threading.InterlockedReference<T!> a, T? b) -> bool
static Louis.Threading.InterlockedReference<T>.operator ==(Louis.Threading.InterlockedReference<T!> a, Louis.Threading.InterlockedReference<T!> b) -> bool
static Louis.Threading.InterlockedReference<T>.operator ==(Louis.Threading.InterlockedReference<T!> a, T? b) -> bool
virtual Louis.Threading.AsyncService.LogSetupCompleted(bool success) -> void
virtual Louis.Threading.AsyncService.SetupAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask<bool>
17 changes: 17 additions & 0 deletions src/Louis/PublicAPI/net47/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,24 @@ Louis.Threading.AsyncServiceSetupResult.NotStarted = 1 -> Louis.Threading.AsyncS
Louis.Threading.AsyncServiceSetupResult.Successful = 0 -> Louis.Threading.AsyncServiceSetupResult
Louis.Threading.AsyncServiceSetupResult.Unsuccessful = 2 -> Louis.Threading.AsyncServiceSetupResult
Louis.Threading.InterlockedFlag.Equals(bool other) -> bool
Louis.Threading.InterlockedReference<T>
Louis.Threading.InterlockedReference<T>.CompareExchange(T? value, T? comparand) -> T?
Louis.Threading.InterlockedReference<T>.Equals(Louis.Threading.InterlockedReference<T!> other) -> bool
Louis.Threading.InterlockedReference<T>.Equals(T? other) -> bool
Louis.Threading.InterlockedReference<T>.Exchange(T? value) -> T?
Louis.Threading.InterlockedReference<T>.InterlockedReference() -> void
Louis.Threading.InterlockedReference<T>.InterlockedReference(T? value) -> void
Louis.Threading.InterlockedReference<T>.IsNull.get -> bool
Louis.Threading.InterlockedReference<T>.Value.get -> T?
Louis.Threading.InterlockedReference<T>.Value.set -> void
override Louis.Threading.InterlockedReference<T>.Equals(object? obj) -> bool
override Louis.Threading.InterlockedReference<T>.GetHashCode() -> int
override Louis.Threading.InterlockedReference<T>.ToString() -> string!
static Louis.Threading.InterlockedFlag.operator !=(Louis.Threading.InterlockedFlag a, bool b) -> bool
static Louis.Threading.InterlockedFlag.operator ==(Louis.Threading.InterlockedFlag a, bool b) -> bool
static Louis.Threading.InterlockedReference<T>.operator !=(Louis.Threading.InterlockedReference<T!> a, Louis.Threading.InterlockedReference<T!> b) -> bool
static Louis.Threading.InterlockedReference<T>.operator !=(Louis.Threading.InterlockedReference<T!> a, T? b) -> bool
static Louis.Threading.InterlockedReference<T>.operator ==(Louis.Threading.InterlockedReference<T!> a, Louis.Threading.InterlockedReference<T!> b) -> bool
static Louis.Threading.InterlockedReference<T>.operator ==(Louis.Threading.InterlockedReference<T!> a, T? b) -> bool
virtual Louis.Threading.AsyncService.LogSetupCompleted(bool success) -> void
virtual Louis.Threading.AsyncService.SetupAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask<bool>
17 changes: 17 additions & 0 deletions src/Louis/PublicAPI/net6.0/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,24 @@ Louis.Threading.AsyncServiceSetupResult.NotStarted = 1 -> Louis.Threading.AsyncS
Louis.Threading.AsyncServiceSetupResult.Successful = 0 -> Louis.Threading.AsyncServiceSetupResult
Louis.Threading.AsyncServiceSetupResult.Unsuccessful = 2 -> Louis.Threading.AsyncServiceSetupResult
Louis.Threading.InterlockedFlag.Equals(bool other) -> bool
Louis.Threading.InterlockedReference<T>
Louis.Threading.InterlockedReference<T>.CompareExchange(T? value, T? comparand) -> T?
Louis.Threading.InterlockedReference<T>.Equals(Louis.Threading.InterlockedReference<T!> other) -> bool
Louis.Threading.InterlockedReference<T>.Equals(T? other) -> bool
Louis.Threading.InterlockedReference<T>.Exchange(T? value) -> T?
Louis.Threading.InterlockedReference<T>.InterlockedReference() -> void
Louis.Threading.InterlockedReference<T>.InterlockedReference(T? value) -> void
Louis.Threading.InterlockedReference<T>.IsNull.get -> bool
Louis.Threading.InterlockedReference<T>.Value.get -> T?
Louis.Threading.InterlockedReference<T>.Value.set -> void
override Louis.Threading.InterlockedReference<T>.Equals(object? obj) -> bool
override Louis.Threading.InterlockedReference<T>.GetHashCode() -> int
override Louis.Threading.InterlockedReference<T>.ToString() -> string!
static Louis.Threading.InterlockedFlag.operator !=(Louis.Threading.InterlockedFlag a, bool b) -> bool
static Louis.Threading.InterlockedFlag.operator ==(Louis.Threading.InterlockedFlag a, bool b) -> bool
static Louis.Threading.InterlockedReference<T>.operator !=(Louis.Threading.InterlockedReference<T!> a, Louis.Threading.InterlockedReference<T!> b) -> bool
static Louis.Threading.InterlockedReference<T>.operator !=(Louis.Threading.InterlockedReference<T!> a, T? b) -> bool
static Louis.Threading.InterlockedReference<T>.operator ==(Louis.Threading.InterlockedReference<T!> a, Louis.Threading.InterlockedReference<T!> b) -> bool
static Louis.Threading.InterlockedReference<T>.operator ==(Louis.Threading.InterlockedReference<T!> a, T? b) -> bool
virtual Louis.Threading.AsyncService.LogSetupCompleted(bool success) -> void
virtual Louis.Threading.AsyncService.SetupAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask<bool>
17 changes: 17 additions & 0 deletions src/Louis/PublicAPI/net7.0/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,26 @@ Louis.Threading.AsyncServiceSetupResult.NotStarted = 1 -> Louis.Threading.AsyncS
Louis.Threading.AsyncServiceSetupResult.Successful = 0 -> Louis.Threading.AsyncServiceSetupResult
Louis.Threading.AsyncServiceSetupResult.Unsuccessful = 2 -> Louis.Threading.AsyncServiceSetupResult
Louis.Threading.InterlockedFlag.Equals(bool other) -> bool
Louis.Threading.InterlockedReference<T>
Louis.Threading.InterlockedReference<T>.CompareExchange(T? value, T? comparand) -> T?
Louis.Threading.InterlockedReference<T>.Equals(Louis.Threading.InterlockedReference<T!> other) -> bool
Louis.Threading.InterlockedReference<T>.Equals(T? other) -> bool
Louis.Threading.InterlockedReference<T>.Exchange(T? value) -> T?
Louis.Threading.InterlockedReference<T>.InterlockedReference() -> void
Louis.Threading.InterlockedReference<T>.InterlockedReference(T? value) -> void
Louis.Threading.InterlockedReference<T>.IsNull.get -> bool
Louis.Threading.InterlockedReference<T>.Value.get -> T?
Louis.Threading.InterlockedReference<T>.Value.set -> void
override Louis.Threading.InterlockedReference<T>.Equals(object? obj) -> bool
override Louis.Threading.InterlockedReference<T>.GetHashCode() -> int
override Louis.Threading.InterlockedReference<T>.ToString() -> string!
static Louis.ComponentModel.SimpleStringConverter.AddToTypeDescriptor<T>() -> void
Louis.Threading.AsyncService.StopAndWaitAsync() -> System.Threading.Tasks.Task<bool>!
static Louis.Threading.InterlockedFlag.operator !=(Louis.Threading.InterlockedFlag a, bool b) -> bool
static Louis.Threading.InterlockedFlag.operator ==(Louis.Threading.InterlockedFlag a, bool b) -> bool
static Louis.Threading.InterlockedReference<T>.operator !=(Louis.Threading.InterlockedReference<T!> a, Louis.Threading.InterlockedReference<T!> b) -> bool
static Louis.Threading.InterlockedReference<T>.operator !=(Louis.Threading.InterlockedReference<T!> a, T? b) -> bool
static Louis.Threading.InterlockedReference<T>.operator ==(Louis.Threading.InterlockedReference<T!> a, Louis.Threading.InterlockedReference<T!> b) -> bool
static Louis.Threading.InterlockedReference<T>.operator ==(Louis.Threading.InterlockedReference<T!> a, T? b) -> bool
virtual Louis.Threading.AsyncService.LogSetupCompleted(bool success) -> void
virtual Louis.Threading.AsyncService.SetupAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask<bool>
17 changes: 17 additions & 0 deletions src/Louis/PublicAPI/net8.0/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,26 @@ Louis.Threading.AsyncServiceSetupResult.NotStarted = 1 -> Louis.Threading.AsyncS
Louis.Threading.AsyncServiceSetupResult.Successful = 0 -> Louis.Threading.AsyncServiceSetupResult
Louis.Threading.AsyncServiceSetupResult.Unsuccessful = 2 -> Louis.Threading.AsyncServiceSetupResult
Louis.Threading.InterlockedFlag.Equals(bool other) -> bool
Louis.Threading.InterlockedReference<T>
Louis.Threading.InterlockedReference<T>.CompareExchange(T? value, T? comparand) -> T?
Louis.Threading.InterlockedReference<T>.Equals(Louis.Threading.InterlockedReference<T!> other) -> bool
Louis.Threading.InterlockedReference<T>.Equals(T? other) -> bool
Louis.Threading.InterlockedReference<T>.Exchange(T? value) -> T?
Louis.Threading.InterlockedReference<T>.InterlockedReference() -> void
Louis.Threading.InterlockedReference<T>.InterlockedReference(T? value) -> void
Louis.Threading.InterlockedReference<T>.IsNull.get -> bool
Louis.Threading.InterlockedReference<T>.Value.get -> T?
Louis.Threading.InterlockedReference<T>.Value.set -> void
override Louis.Threading.InterlockedReference<T>.Equals(object? obj) -> bool
override Louis.Threading.InterlockedReference<T>.GetHashCode() -> int
override Louis.Threading.InterlockedReference<T>.ToString() -> string!
static Louis.ComponentModel.SimpleStringConverter.AddToTypeDescriptor<T>() -> void
Louis.Threading.AsyncService.StopAndWaitAsync() -> System.Threading.Tasks.Task<bool>!
static Louis.Threading.InterlockedFlag.operator !=(Louis.Threading.InterlockedFlag a, bool b) -> bool
static Louis.Threading.InterlockedFlag.operator ==(Louis.Threading.InterlockedFlag a, bool b) -> bool
static Louis.Threading.InterlockedReference<T>.operator !=(Louis.Threading.InterlockedReference<T!> a, Louis.Threading.InterlockedReference<T!> b) -> bool
static Louis.Threading.InterlockedReference<T>.operator !=(Louis.Threading.InterlockedReference<T!> a, T? b) -> bool
static Louis.Threading.InterlockedReference<T>.operator ==(Louis.Threading.InterlockedReference<T!> a, Louis.Threading.InterlockedReference<T!> b) -> bool
static Louis.Threading.InterlockedReference<T>.operator ==(Louis.Threading.InterlockedReference<T!> a, T? b) -> bool
virtual Louis.Threading.AsyncService.LogSetupCompleted(bool success) -> void
virtual Louis.Threading.AsyncService.SetupAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask<bool>
17 changes: 17 additions & 0 deletions src/Louis/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,24 @@ Louis.Threading.AsyncServiceSetupResult.NotStarted = 1 -> Louis.Threading.AsyncS
Louis.Threading.AsyncServiceSetupResult.Successful = 0 -> Louis.Threading.AsyncServiceSetupResult
Louis.Threading.AsyncServiceSetupResult.Unsuccessful = 2 -> Louis.Threading.AsyncServiceSetupResult
Louis.Threading.InterlockedFlag.Equals(bool other) -> bool
Louis.Threading.InterlockedReference<T>
Louis.Threading.InterlockedReference<T>.CompareExchange(T? value, T? comparand) -> T?
Louis.Threading.InterlockedReference<T>.Equals(Louis.Threading.InterlockedReference<T!> other) -> bool
Louis.Threading.InterlockedReference<T>.Equals(T? other) -> bool
Louis.Threading.InterlockedReference<T>.Exchange(T? value) -> T?
Louis.Threading.InterlockedReference<T>.InterlockedReference() -> void
Louis.Threading.InterlockedReference<T>.InterlockedReference(T? value) -> void
Louis.Threading.InterlockedReference<T>.IsNull.get -> bool
Louis.Threading.InterlockedReference<T>.Value.get -> T?
Louis.Threading.InterlockedReference<T>.Value.set -> void
override Louis.Threading.InterlockedReference<T>.Equals(object? obj) -> bool
override Louis.Threading.InterlockedReference<T>.GetHashCode() -> int
override Louis.Threading.InterlockedReference<T>.ToString() -> string!
static Louis.Threading.InterlockedFlag.operator !=(Louis.Threading.InterlockedFlag a, bool b) -> bool
static Louis.Threading.InterlockedFlag.operator ==(Louis.Threading.InterlockedFlag a, bool b) -> bool
static Louis.Threading.InterlockedReference<T>.operator !=(Louis.Threading.InterlockedReference<T!> a, Louis.Threading.InterlockedReference<T!> b) -> bool
static Louis.Threading.InterlockedReference<T>.operator !=(Louis.Threading.InterlockedReference<T!> a, T? b) -> bool
static Louis.Threading.InterlockedReference<T>.operator ==(Louis.Threading.InterlockedReference<T!> a, Louis.Threading.InterlockedReference<T!> b) -> bool
static Louis.Threading.InterlockedReference<T>.operator ==(Louis.Threading.InterlockedReference<T!> a, T? b) -> bool
virtual Louis.Threading.AsyncService.LogSetupCompleted(bool success) -> void
virtual Louis.Threading.AsyncService.SetupAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask<bool>
17 changes: 17 additions & 0 deletions src/Louis/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,24 @@ Louis.Threading.AsyncServiceSetupResult.NotStarted = 1 -> Louis.Threading.AsyncS
Louis.Threading.AsyncServiceSetupResult.Successful = 0 -> Louis.Threading.AsyncServiceSetupResult
Louis.Threading.AsyncServiceSetupResult.Unsuccessful = 2 -> Louis.Threading.AsyncServiceSetupResult
Louis.Threading.InterlockedFlag.Equals(bool other) -> bool
Louis.Threading.InterlockedReference<T>
Louis.Threading.InterlockedReference<T>.CompareExchange(T? value, T? comparand) -> T?
Louis.Threading.InterlockedReference<T>.Equals(Louis.Threading.InterlockedReference<T!> other) -> bool
Louis.Threading.InterlockedReference<T>.Equals(T? other) -> bool
Louis.Threading.InterlockedReference<T>.Exchange(T? value) -> T?
Louis.Threading.InterlockedReference<T>.InterlockedReference() -> void
Louis.Threading.InterlockedReference<T>.InterlockedReference(T? value) -> void
Louis.Threading.InterlockedReference<T>.IsNull.get -> bool
Louis.Threading.InterlockedReference<T>.Value.get -> T?
Louis.Threading.InterlockedReference<T>.Value.set -> void
override Louis.Threading.InterlockedReference<T>.Equals(object? obj) -> bool
override Louis.Threading.InterlockedReference<T>.GetHashCode() -> int
override Louis.Threading.InterlockedReference<T>.ToString() -> string!
static Louis.Threading.InterlockedFlag.operator !=(Louis.Threading.InterlockedFlag a, bool b) -> bool
static Louis.Threading.InterlockedFlag.operator ==(Louis.Threading.InterlockedFlag a, bool b) -> bool
static Louis.Threading.InterlockedReference<T>.operator !=(Louis.Threading.InterlockedReference<T!> a, Louis.Threading.InterlockedReference<T!> b) -> bool
static Louis.Threading.InterlockedReference<T>.operator !=(Louis.Threading.InterlockedReference<T!> a, T? b) -> bool
static Louis.Threading.InterlockedReference<T>.operator ==(Louis.Threading.InterlockedReference<T!> a, Louis.Threading.InterlockedReference<T!> b) -> bool
static Louis.Threading.InterlockedReference<T>.operator ==(Louis.Threading.InterlockedReference<T!> a, T? b) -> bool
virtual Louis.Threading.AsyncService.LogSetupCompleted(bool success) -> void
virtual Louis.Threading.AsyncService.SetupAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask<bool>
Loading

0 comments on commit 125cea6

Please sign in to comment.