---
title: "Implicit Request Contexts"
url: https://docs.zeroc.com/ice/3.8/runtime/invocation/request-contexts/implicit-request-contexts
docs_index: https://docs.zeroc.com/llms.txt
---

> For an index of every page, see [llms.txt](https://docs.zeroc.com/llms.txt).

# Implicit Request Contexts

This page is written for C++, C#, Java, JavaScript, MATLAB, Python, Ruby, and Swift.

Parts of this page are for some programming languages only, and name them. For one language's text alone, see [C++](https://docs.zeroc.com/ice/3.8/runtime/invocation/request-contexts/implicit-request-contexts/cpp.md), [C#](https://docs.zeroc.com/ice/3.8/runtime/invocation/request-contexts/implicit-request-contexts/csharp.md), [Java](https://docs.zeroc.com/ice/3.8/runtime/invocation/request-contexts/implicit-request-contexts/java.md), [JavaScript](https://docs.zeroc.com/ice/3.8/runtime/invocation/request-contexts/implicit-request-contexts/js.md), [MATLAB](https://docs.zeroc.com/ice/3.8/runtime/invocation/request-contexts/implicit-request-contexts/matlab.md), [Python](https://docs.zeroc.com/ice/3.8/runtime/invocation/request-contexts/implicit-request-contexts/python.md), [Ruby](https://docs.zeroc.com/ice/3.8/runtime/invocation/request-contexts/implicit-request-contexts/ruby.md), and [Swift](https://docs.zeroc.com/ice/3.8/runtime/invocation/request-contexts/implicit-request-contexts/swift.md).

An implicit request context belongs to a communicator: Ice sends it with each invocation made through the proxies of this communicator, unless the invocation has an [explicit context](https://docs.zeroc.com/ice/3.8/runtime/invocation/request-contexts/explicit-request-contexts.md).

## Configuring the Implicit Context

The [Ice.ImplicitContext](https://docs.zeroc.com/ice/3.8/property-reference/ice-properties.md#ice.implicitcontext) property specifies whether the communicator has an implicit context:

> **C++, C#, Java, MATLAB, Python, Ruby, and Swift**
>
> - `None` *(the default)*: the communicator has no implicit context.
> - `Shared`: the communicator has one implicit context, which all threads can use concurrently.
> - `PerThread`: the communicator has a separate implicit context for each thread.

> **JavaScript**
>
> - `None` *(the default)*: the communicator has no implicit context.
> - `Shared`: the communicator has one implicit context.

## Using the Implicit Context

`getImplicitContext` on the communicator returns its implicit context, an object with methods to read and update the context's entries. (C++, C#, Java, MATLAB, Python, Ruby, and Swift: With `PerThread`, call `getImplicitContext` and update the context on the thread that makes the invocations.)

> **C# and Swift**
>
> > **Warning**
> >
> > `PerThread` is not usable in code that makes invocations with `await`: this code can resume on a different thread, with a different implicit context, after each `await`.

> **C++**
>
> ```cpp
> Ice::ImplicitContextPtr implicitContext = communicator->getImplicitContext();
> implicitContext->put("language", "fr");
>
> // This invocation sends the "language" entry of the implicit context.
> string greeting = greeter->greet(name);
> ```

> **C#**
>
> ```csharp
> Ice.ImplicitContext implicitContext = communicator.getImplicitContext();
> implicitContext.put("language", "fr");
>
> // This invocation sends the "language" entry of the implicit context.
> string greeting = await greeter.GreetAsync(name);
> ```

> **Java**
>
> ```java
> ImplicitContext implicitContext = communicator.getImplicitContext();
> implicitContext.put("language", "fr");
>
> // This invocation sends the "language" entry of the implicit context.
> String greeting = greeter.greet(name);
> ```

> **JavaScript**
>
> ```js
> const implicitContext = communicator.getImplicitContext();
> implicitContext.put("language", "fr");
>
> // This invocation sends the "language" entry of the implicit context.
> const greeting = await greeter.greet(name);
> ```

> **MATLAB**
>
> ```matlab
> implicitContext = communicator.getImplicitContext();
> implicitContext.put('language', 'fr');
>
> % This invocation sends the 'language' entry of the implicit context.
> greeting = greeter.greet(name);
> ```

> **Python**
>
> ```py
> implicitContext = communicator.getImplicitContext()
> implicitContext.put("language", "fr")
>
> # This invocation sends the "language" entry of the implicit context.
> greeting = await greeter.greetAsync(name)
> ```

> **Ruby**
>
> ```ruby
> implicitContext = communicator.getImplicitContext()
> implicitContext.put("language", "fr")
>
> # This invocation sends the "language" entry of the implicit context.
> greeting = greeter.greet(name)
> ```

> **Swift**
>
> ```swift
> let implicitContext = communicator.getImplicitContext()!
> implicitContext.put(key: "language", value: "fr")
>
> // This invocation sends the "language" entry of the implicit context.
> let greeting = try await greeter.greet(name)
> ```
