Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean ups in events, space and universe #632

Merged
merged 29 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9797eac
Refactoring: dispatchTimeEvent:during: doesn't need to cull the space
tinchodias Oct 19, 2024
d10fdd0
Reformat code and improve comment in dispatchEvent:
tinchodias Oct 19, 2024
63bdc4e
Refactoring: Don't talk to space's eventDispatcher directly; talk to …
tinchodias Oct 20, 2024
652c470
Refactoring: inline initDispatcher
tinchodias Oct 20, 2024
d326997
Fix two occurrences of dispatching events bypassing the space, i.e. t…
tinchodias Oct 20, 2024
0b3a1c6
Fix two occurrences of dispatching events bypassing the space, i.e. t…
tinchodias Oct 20, 2024
2b81c76
Fix simulateEvents:on: to better emulate the dispatch of BlSpaceEvent…
tinchodias Oct 20, 2024
87d5c0e
Little improvement on when:doOnce: (refactoring)
tinchodias Oct 21, 2024
b89cce1
Make addEventFilterOn:do: return the new handler
tinchodias Oct 21, 2024
2091afb
BlParallelUniverse was missing hasPostponedActions
tinchodias Oct 22, 2024
ab142b1
BlHeadlessHostSpace was missing isValid, as other host spaces have
tinchodias Oct 22, 2024
3ecdb2d
Send #universe instead of referencing BlParallelUniverse
tinchodias Oct 22, 2024
03a977d
Deprecate event target's #when:doOnce: in favor of #addEventHandlerOn…
tinchodias Oct 22, 2024
b132c14
BlSpace: Deprecate pulseRequested in favor of isPulseRequested
tinchodias Oct 23, 2024
1d55111
Fix parent commit
tinchodias Oct 23, 2024
01a9b26
Remove BlSpaceDestroyedEvent
tinchodias Oct 24, 2024
9723747
BlMorphicSteppingHost: Send #universe instead of referencing BlParall…
tinchodias Oct 24, 2024
a15905a
Cleanup and reformat some methods in BlSpaceManager and BlParallelUni…
tinchodias Oct 24, 2024
697b476
BlParallelUniverse close and detach: remove double check for isOpened…
tinchodias Oct 24, 2024
06630c6
Revert "BlParallelUniverse close and detach: remove double check for …
tinchodias Oct 24, 2024
ab1aa33
Only reformat and fix comments of closeSpace: and detachSpace:
tinchodias Oct 24, 2024
e2550e8
Make closeSpaceSynchronously: delegate on detachSpaceSynchronously:
tinchodias Oct 24, 2024
47df523
Make openSpaceSynchronously: delegate on attachSpaceSynchronously:
tinchodias Oct 24, 2024
0a80636
Support siwtching host of an opened space
tinchodias Oct 24, 2024
fb1a3f9
Delete almost all BeaconSignals
tinchodias Oct 24, 2024
fc73324
Remove id from BlSpace, BlTask and BlParallelUniverse
tinchodias Oct 24, 2024
29aac9a
Merge BlSpaceManager into BlParallelUniverse
tinchodias Oct 24, 2024
ab62c1a
Remove 2 BlSpace methods in protocol 'NOT-USED-private-change'
tinchodias Oct 24, 2024
f491f6e
Make again BlSpaceEventTest be subclass of TestCase
tinchodias Oct 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Bloc-DevTool/BlBenchmarkConsole.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ BlBenchmarkConsole >> listenSpace: aSpace [
lastTime := aSpace time now.
frames := 0.
framesLimit := 120.
aSpace eventDispatcher addEventHandler:
aSpace addEventHandler:
(BlEventHandler on: BlSpaceRenderEndEvent do: [ :evt |
frames := frames + 1.
frames % framesLimit = 0
Expand All @@ -86,11 +86,11 @@ BlBenchmarkConsole >> listenSpace: aSpace [
lastTime := evt end.
frames := 0 ].
self renderTime: (evt end - evt start) ]).
aSpace eventDispatcher addEventHandler:
aSpace addEventHandler:
(BlEventHandler on: BlSpaceEventsProcessedEvent do: [ :evt |
self eventProcessingTime: (evt end - evt start).
]).
aSpace eventDispatcher addEventHandler:
aSpace addEventHandler:
(BlEventHandler on: BlSpaceLayoutEndEvent do: [ :evt |
self layoutTime: (evt end - evt start).
])
Expand Down
2 changes: 1 addition & 1 deletion src/Bloc-Tests/BlHostPulseLoopTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ BlHostPulseLoopTest >> testOpeningAnSpaceDeferingAnErrorKeepsLoopRunning [
aSpace show.

logger := MemoryLogger new.
logger runFor: BlParallelUniverseErrorDuringPulse during: [
logger runFor: BlParallelUniverseErrorDuringPulseSignal during: [
aSpace universe defer: [ 1 error: 'I am the debugger to kill' ].
[aSpace universe hasDeferredActions] whileTrue: [
100 milliSeconds wait
Expand Down
23 changes: 0 additions & 23 deletions src/Bloc-Tests/BlSpaceEventTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,6 @@ BlSpaceEventTest >> testSpaceClosed [
self assert: count equals: 1
]

{ #category : #tests }
BlSpaceEventTest >> testSpaceDestroyed [

| events |
events := OrderedCollection new.

space
addEventHandlerOn: BlSpaceClosedEvent
do: [ events add: #closed ].
space
addEventHandlerOn: BlSpaceDestroyedEvent
do: [ events add: #destroyed ].

space show.
self waitPulses.
self assert: events size equals: 0.

space close.
self waitPulses.
self assert: events size equals: 2.
self assert: events asArray equals: #( closed destroyed )
]

{ #category : #tests }
BlSpaceEventTest >> testSpaceShown [

Expand Down
17 changes: 8 additions & 9 deletions src/Bloc/BlElement.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -3933,16 +3933,15 @@ BlElement >> whenLayoutedDo: aBlock [

{ #category : #'geometry hooks' }
BlElement >> whenLayoutedDoOnce: aBlock [
"As an example of use, imagine you need to get the actual size of an element.
"Evaluate block passed as argument after the layout applied.

As an example of use, imagine you need to get the actual size of an element.
The size is computed by the layout.
Thus, if one need to get the size of an element one have to be sure that its layout applied.
This is the purpose of #whenLayoutedDoOne: (when layout applied do once) which intention is to run
the block passed as argument only one time just after the layout applied.

** notice ** that my use is not encouraged except for debugging or for particular purposes
ouside usual Bloc coding
"
self when: BlElementLayoutComputedEvent doOnce: [ :event | aBlock cull: event ].
Thus, if one need to get the size of an element one have to be sure that its layout applied."

^ self
addEventHandlerOn: BlElementLayoutComputedEvent
doOnce: aBlock
]

{ #category : #'api - bounds' }
Expand Down
6 changes: 6 additions & 0 deletions src/Bloc/BlHeadlessHostSpace.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ BlHeadlessHostSpace >> isResizable [
^ true
]

{ #category : #testing }
BlHeadlessHostSpace >> isValid [

^ true
]

{ #category : #'host space - testing' }
BlHeadlessHostSpace >> isVisible [
"Return true if underlying window is shown, false otherwise.
Expand Down
6 changes: 6 additions & 0 deletions src/Bloc/BlHost.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Class {
#category : #'Bloc-Universe - Host'
}

{ #category : #testing }
BlHost class >> hasUniverse [

^ BlParallelUniverse existsForHost: self
]

{ #category : #'api - lifecycle' }
BlHost class >> isRunning [
^ self subclassResponsibility
Expand Down
4 changes: 2 additions & 2 deletions src/Bloc/BlHostPulseLoop.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ BlHostPulseLoop >> loopIteration [

[
pulseStartMS := Time millisecondClockValue.
universe := BlParallelUniverse forHost: hostClass.
universe := hostClass universe.
universe pulse.
pulseDurationMS := Time millisecondClockValue - pulseStartMS.
self waitUntilNextPulse. ]
on: Exception
do: [ :e |
self forceStartNewUIProcess.
self forceStartNewUIProcess.
e pass ].

"Returns true to continue looping"
Expand Down
Loading