Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
c_bind.cpp
Go to the documentation of this file.
1#include "c_bind.hpp"
6#ifndef NO_MULTITHREADING
7#include <mutex>
8#endif
9
10namespace bb::bbapi {
11
12// Global BBApiRequest object in anonymous namespace
13namespace {
14// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
15BBApiRequest global_request;
16#ifndef NO_MULTITHREADING
17// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
18std::mutex request_mutex;
19#endif
20} // namespace
21
29{
30#ifndef NO_MULTITHREADING
31 // Try to lock, but error if it would block (indicating concurrent access)
33 if (!lock.owns_lock()) {
34 throw_or_abort("BB API is meant for single-threaded (queued) use only");
35 }
36#endif
37
38 // Execute the command using the global request and return the response
39 return execute(global_request, std::move(command));
40}
41
42} // namespace bb::bbapi
43
44// Use CBIND macro to export the bbapi function for WASM
Shared type definitions for the Barretenberg RPC API.
A wrapper around std::variant that provides msgpack serialization based on type names.
#define CBIND_NOSCHEMA(cname, func)
CommandResponse execute(BBApiRequest &request, Command &&command)
Executes a command by visiting a variant of all possible commands.
CommandResponse bbapi(Command &&command)
Main API function that processes commands and returns responses.
Definition c_bind.cpp:28
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
Definition tuple.hpp:13
void throw_or_abort(std::string const &err)