Skip to content
Commit 27426cb1 authored by Peter Goodspeed-Niklaus's avatar Peter Goodspeed-Niklaus
Browse files

Use function trait objects for exchangeable host functions

**Motivation**

The current state of exchangeable functions is that they all expect
raw function pointers: they're initialized with raw pointers to the
initial function, which means that every replacement must also be
a raw function pointer.

The problem with this arrangement is that this prevents us from
swapping in a closure. In Cumulus, we've discovered a case for which
it would be very convenient to swap in a closure which captures an
additional piece of data. This change enables this possibility.

**Drawbacks**

Function calls to a trait object pass through an additional layer
of indirection, which produces a negligable but non-zero additional
cost per function call.

**Breaking Changes**

Every call `foo.replace_implementation(new_impl)` must change to
`foo.replace_implementation(&new_impl)`, which is a simple but
possibly pervasive change.
parent 6c0232b9
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