Skip to content

Commit

Permalink
chore: event execution first executes action and then notifies observers
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomoaccursi committed Jan 12, 2024
1 parent 98b81be commit 0c1be58
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/kotlin/entity/EventImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ class EventImpl(
override val tau: Time get() = timeDistribution.getNextOccurrence()

override suspend fun execute() {
actions.forEach { it.execute() }
observerLatch = CountDownLatch(executionFlow.subscriptionCount.value)
executionFlow.emit(this)
withContext(Dispatchers.IO) {
observerLatch.await()
}
actions.forEach { it.execute() }
}

override fun canExecute(): Boolean {
Expand Down

0 comments on commit 0c1be58

Please sign in to comment.