Skip to content
Verified Commit c227c358 authored by Alberto Miranda's avatar Alberto Miranda
Browse files

Add specific types to enable converting between RPC and API types

This commit adds two generic templated types (managed_rpc_type<T> and
unmanaged_rpc_type<T>) that simplify the lifetime management of any C-types
created by Margo RPCs. They also offer conversion functions that allow
converting between C RPC types and C++ API types.

Both types internally create and store pointers to the C-structures required
(or produced) by the RPC engine, but differ in how they manage these
structures:

- The `managed_rpc_type<T>` template internally manages the lifetime of the
  C underlying object and ensures that its destruction function will be
  called when the destructor for `managed_rpc_type<T>` is called.

- The `unmanaged_rpc_type<T>` template only creates the C underlying
  object, but does not destroy it. This is useful when conversions
  are needed but the underlying data will be automatically destroyed by Margo.

Specific conversions are implemented as template specializations. For
example, `template <> struct admire::managed_rpc_type<admire::job>`
allows converting from an `admire::job` instance to a newly-created `ADM_job_t`
via its `get()` function. On the other hand,
`template <> struct admire::managed_rpc_type<ADM_job_t>` allows converting
from an existing `ADM_job_t` to an `admire::job` instance, also via its
`get()` function.
parent 9bd144ae
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment