emscripten-core / emscripten-core/emscripten

Feature request: allow to return value from C++ proxying API

Open
#20,611 1 comment 2 reactions 1 assignee Claimed by @tlively View on GitHub
multithreading
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

It would be nice to be able to return custom value directly from `queue.proxySync(...)` / `proxySyncWithCtx` / `proxyCallback`'s callback high-level APIs.

Most proxying operations require returning a value, but right now the closest workaround is to create a value with default constructor and override it from the callback, which is a bit cumbersome and also not ideal when default constructor is potentially expensive. Another alternative is to use `std::optional` + `emplace`, which is less expensive, but even more cumbersome.

I'm not sure how that would play with `bool` - I guess `bool` should stay as the return type for `proxySync` and then `std::optional` would be the return type for `proxySync`? Personally I almost always need to hard assert on proxying being successful, so I'd also be happy with something like `T proxySyncChecked()` which would just throw exception / abort on proxying failure and return value directly otherwise.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.