void call_async(Core dest, F func) { static_assert(std::is_same<R, decltype(func())>::value, "return type of callable must match the type of this Promise"); _result.reset(); delegate_ops++; delegate_async_ops++; Core origin = Grappa::mycore(); if (dest == origin) { // short-circuit if local delegate_targets++; delegate_short_circuits++; fill(func()); } else { start_time = Grappa::timestamp(); send_heap_message(dest, [origin, func, this] { delegate_targets++; R val = func(); // TODO: replace with handler-safe send_message send_heap_message(origin, [val, this] { this->network_time = Grappa::timestamp(); Grappa::impl::record_network_latency(this->start_time); this->fill(val); }); }); // send message } }