Skip to content

Commit

Permalink
GtAnnouncingTimeCachedObject: rename retrievingMessage to retrievingO…
Browse files Browse the repository at this point in the history
…bject
  • Loading branch information
akgrant43 committed Dec 11, 2024
1 parent 0f25fa1 commit 89275bb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
29 changes: 20 additions & 9 deletions src/GToolkit-Utility-Basic/GtAnnouncingTimeCachedObject.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Class {
#superclass : #GtTimeCachedObject,
#instVars : [
'announcer',
'retrievingMessage'
'retrievingValue'
],
#category : #'GToolkit-Utility-Basic'
}
Expand All @@ -27,11 +27,11 @@ GtAnnouncingTimeCachedObject class >> get: aBlock timeout: aDuration announcer:
]

{ #category : #'instance creation' }
GtAnnouncingTimeCachedObject class >> get: aBlock timeout: aDuration announcer: anAnnouncer retrievingMessage: aString [
GtAnnouncingTimeCachedObject class >> get: aBlock timeout: aDuration announcer: anAnnouncer retrievingValue: aString [

^ (self new initialize: aBlock timeout: aDuration)
announcer: anAnnouncer;
retrievingMessage: aString
retrievingValue: aString
]

{ #category : #accessing }
Expand All @@ -44,20 +44,29 @@ GtAnnouncingTimeCachedObject >> announcer: anObject [
announcer := anObject
]

{ #category : #'as yet unclassified' }
GtAnnouncingTimeCachedObject >> initialize [

super initialize.
"Self is a flag that the value hasn't been set,
allowing nil to be a retrievingMessage"
retrievingValue := self.
]

{ #category : #accessing }
GtAnnouncingTimeCachedObject >> retrievingMessage [
^ retrievingMessage
GtAnnouncingTimeCachedObject >> retrievingValue [
^ retrievingValue
]

{ #category : #accessing }
GtAnnouncingTimeCachedObject >> retrievingMessage: anObject [
retrievingMessage := anObject
GtAnnouncingTimeCachedObject >> retrievingValue: anObject [
retrievingValue := anObject
]

{ #category : #private }
GtAnnouncingTimeCachedObject >> updateAndAnnounce [

[ self newValue ] asAsyncPromise
[ super valueWithin: cacheTime ] asAsyncPromise
then: [ :newValue |
[ announcer announce: (GtTimeCachedObjectAnnouncement
newValue: newValue cache: self) ]
Expand All @@ -73,5 +82,7 @@ GtAnnouncingTimeCachedObject >> valueWithin: aDuration [

DateAndTime now <= self cacheTimeout ifTrue: [ ^ value ].
self updateAndAnnounce.
^ retrievingMessage ifNil: [ value ].
^ retrievingValue == self
ifTrue: [ value ]
ifFalse: [ retrievingValue ].
]
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ GtInheritedMethodsSortFunction >> compareMethodNameOf: aMethodOrName1 withMethod
ifFalse: [ methodName2 isBinary threeWayCompareTo: methodName1 isBinary ]
]

{ #category : #comparing }
GtInheritedMethodsSortFunction >> hash [
^ self class hash
]

{ #category : #'private - comparison' }
GtInheritedMethodsSortFunction >> hasMethodNameOf: aMethodOrName [
<return: #Symbol>
Expand All @@ -121,6 +116,11 @@ GtInheritedMethodsSortFunction >> hasMethodNameOf: aMethodOrName [
^ [ aMethodOrName selector notNil ] on: Error do: [ :ex | ex return: false ]
]

{ #category : #comparing }
GtInheritedMethodsSortFunction >> hash [
^ self class hash
]

{ #category : #'private - comparison' }
GtInheritedMethodsSortFunction >> methodNameOf: aMethodOrName [
<return: #Symbol>
Expand Down
10 changes: 5 additions & 5 deletions src/GToolkit-Utility-Basic/GtMethodsSortFunction.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ GtMethodsSortFunction >> compareMethodNameOf: aMethodOrName1 withMethodNameOf: a
ifFalse: [ methodName2 isBinary threeWayCompareTo: methodName1 isBinary ]
]

{ #category : #comparing }
GtMethodsSortFunction >> hash [
^ self class hash
]

{ #category : #'private - comparison' }
GtMethodsSortFunction >> hasMethodNameOf: aMethodOrName [
<return: #Symbol>
Expand All @@ -132,6 +127,11 @@ GtMethodsSortFunction >> hasMethodNameOf: aMethodOrName [
^ [ aMethodOrName selector notNil ] on: Error do: [ :ex | ex return: false ]
]

{ #category : #comparing }
GtMethodsSortFunction >> hash [
^ self class hash
]

{ #category : #'private - comparison' }
GtMethodsSortFunction >> methodNameOf: aMethodOrName [
<return: #Symbol>
Expand Down

0 comments on commit 89275bb

Please sign in to comment.