> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/holoscan/sdk-user-guide/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/holoscan/sdk-user-guide/_mcp/server.

# holoscan::Executor

> Base class for all executors.

Base class for all executors.

An `Executor` that manages the execution of a [Fragment](fragment) on a physical node. The framework provides a default `Executor` that uses a GXF [Scheduler](scheduler) to execute an [Application](application).

```cpp showLineNumbers={false}
#include <holoscan/executor.hpp>
```

***

## Constructors

### Executor \[#executor]

```cpp showLineNumbers={false}
holoscan::Executor::Executor(
    Fragment *fragment
)
```

Construct a new `Executor` object.

**Parameters**

The pointer to the fragment of the executor.

The following overloads are deleted to prevent misuse:

```cpp showLineNumbers={false}
holoscan::Executor::Executor() = delete;
holoscan::Executor::Executor(const Executor &) = delete;
```

### Destructor \[#destructor]

### \~Executor

```cpp showLineNumbers={false}
virtual holoscan::Executor::~Executor() = default
```

***

## Assignment operators

### operator= \[#operator\_assign]

```cpp showLineNumbers={false}
Executor & holoscan::Executor::operator=(
    const Executor &
) = delete
```

***

## Methods

### run \[#run]

```cpp showLineNumbers={false}
virtual void holoscan::Executor::run(
    OperatorFlowGraph &graph
)
```

Run the graph.

**Parameters**

The reference to the graph.

### run\_async \[#runasync]

```cpp showLineNumbers={false}
virtual std::future<void> holoscan::Executor::run_async(
    OperatorFlowGraph &graph
)
```

Run the graph asynchronously.

**Returns:** The future object.

**Parameters**

The reference to the graph.

### interrupt \[#interrupt]

```cpp showLineNumbers={false}
virtual bool holoscan::Executor::interrupt()
```

Interrupt the execution.

**Returns:** true if the interrupt was successful (graph was running), false if the graph was not running (already stopped or not started).

### wait \[#wait]

```cpp showLineNumbers={false}
virtual void holoscan::Executor::wait()
```

Wait for the execution to complete.

This method blocks until the graph execution (started by run\_async or interrupted by interrupt()) completes. Should be called after interrupt() to ensure the scheduler has fully stopped before performing cleanup operations.

Only call this if interrupt() returned true. Calling wait() when the graph is not running can cause issues with concurrent cleanup.

### fragment \[#fragment]

```cpp showLineNumbers={false}
void holoscan::Executor::fragment(
    Fragment *fragment
)
```

Set the pointer to the fragment of the executor.

**Parameters**

The pointer to the fragment of the executor.

```cpp showLineNumbers={false}
Fragment * holoscan::Executor::fragment()
```

Get a pointer to [Fragment](fragment) object.

**Returns:** The Pointer to [Fragment](fragment) object.

### context \[#context]

virtual

```cpp showLineNumbers={false}
virtual void holoscan::Executor::context(
    void *context
)
```

Set the context.

**Parameters**

The context.

```cpp showLineNumbers={false}
void * holoscan::Executor::context()
```

Get the context.

**Returns:** The context.

### owns\_context \[#ownscontext]

```cpp showLineNumbers={false}
bool holoscan::Executor::owns_context()
```

Get whether the context is owned by the executor.

**Returns:** true if the context is owned by the executor. Otherwise, false.

### context\_uint64 \[#contextuint64]

```cpp showLineNumbers={false}
void holoscan::Executor::context_uint64(
    uint64_t context
)
```

```cpp showLineNumbers={false}
uint64_t holoscan::Executor::context_uint64()
```

### extension\_manager \[#extensionmanager]

```cpp showLineNumbers={false}
virtual std::shared_ptr<ExtensionManager> holoscan::Executor::extension_manager()
```

Get the extension manager.

**Returns:** The shared pointer of the extension manager.

### exception \[#exception]

```cpp showLineNumbers={false}
void holoscan::Executor::exception(
    const std::exception_ptr &e
)
```

Set the exception.

This method is called by the framework to store the exception that occurred during the execution of the fragment. If the exception is set, this exception is rethrown by the framework after the execution of the fragment.

**Parameters**

The exception to store.

```cpp showLineNumbers={false}
const std::exception_ptr & holoscan::Executor::exception()
```

Get the stored exception.

This method is called by the framework to get the stored exception that occurred during the execution of the fragment. If the exception is set, this exception is rethrown by the framework after the execution of the fragment.

**Returns:** The reference to the stored exception.

### initialize\_fragment \[#initializefragment]

```cpp showLineNumbers={false}
virtual bool holoscan::Executor::initialize_fragment()
```

Initialize the fragment\_ in this `Executor`.

This method is called by run() to initialize the fragment and the graph of operators in the fragment before execution.

**Returns:** true if fragment initialization is successful. Otherwise, false.

### initialize\_operator \[#initializeoperator]

```cpp showLineNumbers={false}
virtual bool holoscan::Executor::initialize_operator(
    Operator *op
)
```

Initialize the given operator.

This method is called by Operator::initialize() to initialize the operator.

Depending on the type of the operator, this method may be overridden to initialize the operator. For example, the default executor (GXFExecutor) initializes the operator using the GXF API and sets the operator's ID to the ID of the GXF codelet.

**Returns:** true if the operator is initialized successfully. Otherwise, false.

**Parameters**

The pointer to the operator.

### initialize\_scheduler \[#initializescheduler]

```cpp showLineNumbers={false}
virtual bool holoscan::Executor::initialize_scheduler(
    Scheduler *sch
)
```

Initialize the given scheduler.

This method is called by Scheduler::initialize() to initialize the operator.

Depending on the type of the scheduler, this method may be overridden to initialize the scheduler. For example, the default executor (GXFExecutor) initializes the scheduler using the GXF API and sets the operator's ID to the ID of the GXF scheduler.

**Returns:** true if the scheduler is initialized successfully. Otherwise, false.

**Parameters**

The pointer to the scheduler.

### initialize\_network\_context \[#initializenetworkcontext]

```cpp showLineNumbers={false}
virtual bool holoscan::Executor::initialize_network_context(
    NetworkContext *network_context
)
```

Initialize the given network context.

This method is called by NetworkContext::initialize() to initialize the operator.

Depending on the type of the network context, this method may be overridden to initialize the network context. For example, the default executor (GXFExecutor) initializes the network context using the GXF API and sets the operator's ID to the ID of the GXF network context.

**Returns:** true if the network context is initialized successfully. Otherwise, false.

**Parameters**

The pointer to the network context.

### initialize\_fragment\_services \[#initializefragmentservices]

```cpp showLineNumbers={false}
virtual bool holoscan::Executor::initialize_fragment_services()
```

Initialize the fragment services for the executor.

This method is called during executor initialization to set up any required fragment services.

Depending on the type of executor, this method may be overridden to initialize specific fragment services. For example, the default executor (GXFExecutor) may initialize fragment services using the GXF API.

**Returns:** true if the fragment services are initialized successfully. Otherwise, false.

### add\_receivers \[#addreceivers]

```cpp showLineNumbers={false}
virtual bool holoscan::Executor::add_receivers(
    const std::shared_ptr<Operator> &op,
    const std::string &receivers_name,
    std::vector<std::string> &new_input_labels,
    std::vector<holoscan::IOSpec *> &iospec_vector
)
```

Add the receivers as input ports of the given operator.

This method is to be called by the Fragment::add\_flow() method to support for the case where the destination input port label points to the parameter name of the downstream operator, and the parameter type is 'std::vector\<holoscan::IOSpec\*>'. This finds a parameter with with 'std::vector\<holoscan::IOSpec\*>' type and create a new input port with a specific label ('parameter name:index'. e.g, 'receivers:0').

**Returns:** true if the receivers are added successfully. Otherwise, false.

**Parameters**

The reference to the shared pointer of the operator.

The name of the receivers whose parameter type is 'std::vector\<holoscan::IOSpec\*>'.

The reference to the vector of input port labels to which the input port labels are added. In the case of multiple receivers, the input port label is updated to 'parameter name:index' (e.g. 'receivers' => 'receivers:0').

The reference to the vector of [IOSpec](iospec) pointers.

### add\_control\_flow \[#addcontrolflow]

```cpp showLineNumbers={false}
virtual bool holoscan::Executor::add_control_flow(
    const std::shared_ptr<Operator> &upstream_op,
    const std::shared_ptr<Operator> &downstream_op
)
```

Add a control flow between two operators.

This method is called by Fragment::add\_flow() to add a control flow between two operators.

**Returns:** true if the control flow is added successfully. Otherwise, false.

**Parameters**

The shared pointer to the upstream operator.

The shared pointer to the downstream operator.

***

## Member variables

| Name                 | Type                                  | Description                                   |
| -------------------- | ------------------------------------- | --------------------------------------------- |
| `fragment_`          | `Fragment *`                          | The fragment of the executor.                 |
| `context_`           | `void *`                              | The context.                                  |
| `owns_context_`      | `bool`                                | Whether the context is owned by the executor. |
| `extension_manager_` | `std::shared_ptr< ExtensionManager >` | The extension manager.                        |
| `exception_`         | `std::exception_ptr`                  | The stored exception.                         |