The {Non}BlockingCall methods of ThreadSafeFunction take the user-provided "callback" argument by value and then copy it into an std::function. I request that the callback argument be taken by forwarding reference and that the callback be forwarded to its final destination. Example:
template <typename DataType, typename Callback>
inline napi_status ThreadSafeFunction::BlockingCall(
DataType* data, Callback&& callback) const {
auto wrapper = [data, callback=std::forward<Callback>(callback)](Env env, Function jsCallback) {
callback(env, jsCallback, data);
};
return CallInternal(new CallbackWrapper(std::move(wrapper)), napi_tsfn_blocking);
}
Note that wrapper is also moved into CallbackWrapper.
The {Non}BlockingCall methods of ThreadSafeFunction take the user-provided "callback" argument by value and then copy it into an std::function. I request that the callback argument be taken by forwarding reference and that the callback be forwarded to its final destination. Example:
Note that
wrapperis also moved into CallbackWrapper.