From 89275bb3ba5e3cea58d6df2af0e388fb671390cf Mon Sep 17 00:00:00 2001 From: Alistair Grant Date: Wed, 11 Dec 2024 18:53:47 +0100 Subject: [PATCH] GtAnnouncingTimeCachedObject: rename retrievingMessage to retrievingObject --- .../GtAnnouncingTimeCachedObject.class.st | 29 +++++++++++++------ .../GtInheritedMethodsSortFunction.class.st | 10 +++---- .../GtMethodsSortFunction.class.st | 10 +++---- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/GToolkit-Utility-Basic/GtAnnouncingTimeCachedObject.class.st b/src/GToolkit-Utility-Basic/GtAnnouncingTimeCachedObject.class.st index f0cc0360..55963e1e 100644 --- a/src/GToolkit-Utility-Basic/GtAnnouncingTimeCachedObject.class.st +++ b/src/GToolkit-Utility-Basic/GtAnnouncingTimeCachedObject.class.st @@ -8,7 +8,7 @@ Class { #superclass : #GtTimeCachedObject, #instVars : [ 'announcer', - 'retrievingMessage' + 'retrievingValue' ], #category : #'GToolkit-Utility-Basic' } @@ -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 } @@ -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) ] @@ -73,5 +82,7 @@ GtAnnouncingTimeCachedObject >> valueWithin: aDuration [ DateAndTime now <= self cacheTimeout ifTrue: [ ^ value ]. self updateAndAnnounce. - ^ retrievingMessage ifNil: [ value ]. + ^ retrievingValue == self + ifTrue: [ value ] + ifFalse: [ retrievingValue ]. ] diff --git a/src/GToolkit-Utility-Basic/GtInheritedMethodsSortFunction.class.st b/src/GToolkit-Utility-Basic/GtInheritedMethodsSortFunction.class.st index 475d6ac0..ef381750 100644 --- a/src/GToolkit-Utility-Basic/GtInheritedMethodsSortFunction.class.st +++ b/src/GToolkit-Utility-Basic/GtInheritedMethodsSortFunction.class.st @@ -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 [ @@ -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 [ diff --git a/src/GToolkit-Utility-Basic/GtMethodsSortFunction.class.st b/src/GToolkit-Utility-Basic/GtMethodsSortFunction.class.st index 2eb7bf32..c4a4f895 100644 --- a/src/GToolkit-Utility-Basic/GtMethodsSortFunction.class.st +++ b/src/GToolkit-Utility-Basic/GtMethodsSortFunction.class.st @@ -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 [ @@ -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 [