Returns parent if it is a CancellableContext, otherwise returns the parent's #cancellableAncestor.
(Context parent)
| 1093 | * {@link #cancellableAncestor}. |
| 1094 | */ |
| 1095 | static CancellableContext cancellableAncestor(Context parent) { |
| 1096 | if (parent instanceof CancellableContext) { |
| 1097 | return (CancellableContext) parent; |
| 1098 | } |
| 1099 | // The parent simply cascades cancellations. |
| 1100 | // Bypass the parent and reference the ancestor directly (may be null). |
| 1101 | return parent.cancellableAncestor; |
| 1102 | } |
| 1103 | |
| 1104 | /** |
| 1105 | * If the ancestry chain length is unreasonably long, then print an error to the log and record |
no outgoing calls