You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A problem with PromiseContext.nowOr(_:) is there's no easy way to tell in the callback whether it's being executed synchronously. If we register the callback from the main thread and use .nowOr(.main) we could use a local variable that we set to false after registering the callback, but this is a little awkward and requires knowing what thread you're registering the callback from.
The thought is maybe we could use TLS to store whether the context is executing synchronously or asynchronously and then expose this value in a property like PromiseContext.isExecutingNow. All cases where a promise callback is invoked should be directly nested inside a call to context.execute so there should be no risk of returning stale info from this property, but this should be audited.
Question: In order to implement .nowOr we piped an isSynchronous flag through the seal enqueuing and context execution. Could we instead use TLS that's set when the seal runs its enqueued callbacks and query it from the context? I didn't implement it that way to begin with because I wasn't sure if there was any way to end up with stale data at the context.execute call (e.g. if there are any context.executes that aren't direct children of a seal.enqueue), but it may be safe to represent it that way.
The text was updated successfully, but these errors were encountered:
A problem with
PromiseContext.nowOr(_:)
is there's no easy way to tell in the callback whether it's being executed synchronously. If we register the callback from the main thread and use.nowOr(.main)
we could use a local variable that we set tofalse
after registering the callback, but this is a little awkward and requires knowing what thread you're registering the callback from.The thought is maybe we could use TLS to store whether the context is executing synchronously or asynchronously and then expose this value in a property like
PromiseContext.isExecutingNow
. All cases where a promise callback is invoked should be directly nested inside a call tocontext.execute
so there should be no risk of returning stale info from this property, but this should be audited.Question: In order to implement
.nowOr
we piped anisSynchronous
flag through the seal enqueuing and context execution. Could we instead use TLS that's set when the seal runs its enqueued callbacks and query it from the context? I didn't implement it that way to begin with because I wasn't sure if there was any way to end up with stale data at thecontext.execute
call (e.g. if there are anycontext.execute
s that aren't direct children of aseal.enqueue
), but it may be safe to represent it that way.The text was updated successfully, but these errors were encountered: