From 5c656efdd1ecfa7a5bfcbf970732c88755fd523b Mon Sep 17 00:00:00 2001 From: Zach Date: Thu, 8 Aug 2024 17:18:19 -0600 Subject: [PATCH] Update README.md --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5637cdf..959b47b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Later -`Later` is a lightweight Swift 6 library designed to simplify asynchronous programming by providing foundational building blocks such as `Future`, `Deferred`, `Stream`, and `Publisher`. These components enable you to manage and coordinate asynchronous tasks, making it easier to write clean and maintainable code. +`Later` is a lightweight Swift 6 library designed to simplify asynchronous programming by providing foundational building blocks such as `Future`, `Deferred`, `Stream`, `SendableValue`, and `Publisher`. These components enable you to manage and coordinate asynchronous tasks, making it easier to write clean and maintainable code. ## Features @@ -9,6 +9,7 @@ - **Stream**: Represents an asynchronous sequence of values emitted over time. - **Publisher**: Allows objects to subscribe to changes in state or data and notifies subscribers when the state or data changes. - **Subscribing**: A protocol for objects that want to observe changes in state or data. +- **SendableValue**: A generic [`Sendable`](https://developer.apple.com/documentation/swift/sendable) value that uses [`OSAllocatedUnfairLock`](https://developer.apple.com/documentation/os/osallocatedunfairlock). ## Installation @@ -217,6 +218,19 @@ do { } ``` +### SendableValue + +SendableValue is a thread-safe wrapper for a value that can be safely shared across concurrent tasks. It allows you to set and retrieve the value asynchronously. + +```swift +let sendableValue = SendableValue(42) +sendableValue.set(value: 100) +let value = await sendableValue.value +#expect(value == 100) +``` + +This ensures that the value is safely managed across different contexts, providing a simple way to handle mutable state in concurrent programming. + ## Contributing Contributions are welcome! Please feel free to submit a pull request or open an issue if you have any suggestions or bug reports. Please create an issue before submitting any pull request to make sure the work isn’t already being worked on by someone else.