MCPcopy Create free account
hub / github.com/WebAssembly/wasm-c-api / callback

Function callback

example/threads.cc:12–20  ·  view source on GitHub ↗

A function to be called from Wasm code.

Source from the content-addressed store, hash-verified

10
11// A function to be called from Wasm code.
12auto callback(
13 void* env, const wasm::vec<wasm::Val>& args, wasm::vec<wasm::Val>& results
14) -> wasm::own<wasm::Trap> {
15 assert(args[0].kind() == wasm::ValKind::I32);
16 std::lock_guard<std::mutex> lock(*reinterpret_cast<std::mutex*>(env));
17 std::cout << "Thread " << args[0].i32() << " running..." << std::endl;
18 std::cout.flush();
19 return nullptr;
20}
21
22
23void run(

Callers

nothing calls this directly

Calls 2

i32Method · 0.80
kindMethod · 0.45

Tested by

no test coverage detected