Create a new context with the given key value set. The new context will cascade cancellation from its parent. Context withCredential = Context.current().withValue(CRED_KEY, cred); withCredential.run(new Runnable() { public void run() { readUserRecords(userId, CRED_KEY.get());
(Key<V> k1, V v1)
| 340 | * are unrelated, have separate keys for them. |
| 341 | */ |
| 342 | public <V> Context withValue(Key<V> k1, V v1) { |
| 343 | Node<Key<?>, Object> newKeyValueEntries = |
| 344 | PersistentHashArrayMappedTrie.put(keyValueEntries, k1, v1); |
| 345 | return new Context(this, newKeyValueEntries); |
| 346 | } |
| 347 | |
| 348 | /** |
| 349 | * Create a new context with the given key value set. The new context will cascade cancellation |