Returns the current value as an Awaitable. The awaitable completes after all previously queued updates have been applied, ensuring a consistent read. @return an awaitable holding the value after pending updates
()
| 148 | * @return an awaitable holding the value after pending updates |
| 149 | */ |
| 150 | public Awaitable<T> getAsync() { |
| 151 | CompletableFuture<T> cf = new CompletableFuture<>(); |
| 152 | updateExecutor.execute(() -> { |
| 153 | rwLock.readLock().lock(); |
| 154 | try { |
| 155 | cf.complete(value); |
| 156 | } finally { |
| 157 | rwLock.readLock().unlock(); |
| 158 | } |
| 159 | }); |
| 160 | return GroovyPromise.of(cf); |
| 161 | } |
| 162 | |
| 163 | /** |
| 164 | * Queues an update function to be applied to the current value. |