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
* Fast-path: we only have to copy/merge if 'addedContext' (which typically has one or two elements)
34
34
* contains copyable element.
35
35
*/
36
36
if (!addedContext.fold(false, hasCopyableElements)) returnthis+ addedContext
37
-
// TODO Here addedContext will be re-evaluated, we can fix it later when the design converges to its final form.
38
37
return foldCopies(this, addedContext, false)
39
38
}
40
39
41
40
privateval hasCopyableElements: (Boolean, CoroutineContext.Element) ->Boolean= { result, it ->
42
41
result || it isCopyableThreadContextElement<*>
43
42
}
44
43
45
-
/*
46
-
* Folds two contexts if there is need to.
44
+
/**
45
+
* Folds two contexts properly applying [CopyableThreadContextElement] rules when necessary.
46
+
* The rules are the following:
47
+
* * If both context do not have CTCE, the sum of two contexts is returned
48
+
* * Every CTCE from left-hand side context that does not have matching (by key) element from right-hand side context
49
+
* is [copied][CopyableThreadContextElement.copyForChild]
50
+
* * Every CTCE from left-hand side context that has matching element in right-hand side context is [merged][CopyableThreadContextElement.mergeForChild]
51
+
* * Every CTCE from right-hand side context that hasn't been merged is copied
52
+
* * Everything else is added to the resulting context as is.
0 commit comments