Skip to content

Commit

Permalink
[feenkcom/gtoolkit#4214] add resetCache and ifSome:ifNonePut: to the …
Browse files Browse the repository at this point in the history
…future cache
  • Loading branch information
syrel committed Nov 28, 2024
1 parent 8136696 commit df17c05
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Futures/AsyncFutureCache.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ AsyncFutureCache >> ifSome: aSomeBlock ifNone: aNoneBlock [
ifNone: aNoneBlock ]
]

{ #category : #controlling }
AsyncFutureCache >> ifSome: aSomeBlock ifNonePut: aNoneBlock [
^ monitor critical: [
value
ifSome: aSomeBlock
ifNone: [
| aValue |
aValue := aNoneBlock value.
value := AsyncOptionalValue some: aValue.
aValue ] ]
]

{ #category : #controlling }
AsyncFutureCache >> ifSome: aSomeBlock ifNonePutPoll: aNoneBlock [
^ monitor critical: [
Expand All @@ -36,3 +48,8 @@ AsyncFutureCache >> initialize [
monitor := Monitor new.
value := AsyncOptionalValue none
]

{ #category : #controlling }
AsyncFutureCache >> resetCache [
^ monitor critical: [ value := AsyncOptionalValue none ]
]

0 comments on commit df17c05

Please sign in to comment.