Skip to content

Commit

Permalink
move entitystate creation out of callback loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Ted Young committed Dec 18, 2024
1 parent 3d01a5f commit 47d549e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions oteps/4316-resource-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,13 @@ class ResourceProvider{
// safely change the resource reference without blocking
AtomicSwap(this.resource, mergedResource);

// create an EntityState event from the entity
var entityState = entity.EntityState();

// calling listeners inside of the lock ensures that the listeners do not fire
// out of order or get called simultaneously by multiple threads, but would
// also allow a poorly implemented listener to block the ResourceProvider.
for (listener in this.listeners) {
// create an EntityState event from the entity
var entityState = entity.EntityState();
listener.OnEntityState(entityState, mergedResource);
}

Expand Down Expand Up @@ -342,12 +343,13 @@ class ResourceProvider{
// safely change the resource reference without blocking
AtomicSwap(this.resource, mergedResource);

// create an EntityState event from the entity
var entityState = entity.EntityState();

// calling listeners inside of the lock ensures that the listeners do not fire
// out of order or get called simultaneously by multiple threads, but would
// also allow a poorly implemented listener to block the ResourceProvider.
for (listener in this.listeners) {
// create an EntityState event from the entity
var entityState = entity.EntityState();
listener.OnEntityState(entityState, mergedResource);
}

Expand Down Expand Up @@ -377,12 +379,13 @@ class ResourceProvider{
// safely change the resource reference without blocking
AtomicSwap(this.resource, mergedResource);

// create an EntityDelete event from the entity
var entityDelete = entity.EntityDelete();

// calling listeners inside of the lock ensures that the listeners do not fire
// out of order or get called simultaneously by multiple threads, but would
// also allow a poorly implemented listener to block the ResourceProvider.
for (listener in this.listeners) {
// create an EntityDelete event from the entity
var entityDelete = entity.EntityDelete();
listener.OnEntityDelete(entityDelete, mergedResource);
}

Expand Down

0 comments on commit 47d549e

Please sign in to comment.