11819edbaSAlex Crichton /** 21819edbaSAlex Crichton * \file wasmtime/engine.hh 31819edbaSAlex Crichton */ 41819edbaSAlex Crichton 51819edbaSAlex Crichton #ifndef WASMTIME_ENGINE_HH 61819edbaSAlex Crichton #define WASMTIME_ENGINE_HH 71819edbaSAlex Crichton 81819edbaSAlex Crichton #include <memory> 91819edbaSAlex Crichton #include <wasmtime/config.hh> 101819edbaSAlex Crichton #include <wasmtime/engine.h> 11*311d023aSAlex Crichton #include <wasmtime/helpers.hh> 121819edbaSAlex Crichton 131819edbaSAlex Crichton namespace wasmtime { 141819edbaSAlex Crichton 151819edbaSAlex Crichton /** 161819edbaSAlex Crichton * \brief Global compilation state in Wasmtime. 171819edbaSAlex Crichton * 181819edbaSAlex Crichton * Created with either default configuration or with a specified instance of 191819edbaSAlex Crichton * configuration, an `Engine` is used as an umbrella "session" for all other 201819edbaSAlex Crichton * operations in Wasmtime. 211819edbaSAlex Crichton */ 221819edbaSAlex Crichton class Engine { 23*311d023aSAlex Crichton /// bridging wasm.h vs wasmtime.h conventions 24*311d023aSAlex Crichton #define wasm_engine_clone wasmtime_engine_clone 25*311d023aSAlex Crichton WASMTIME_CLONE_WRAPPER(Engine, wasm_engine); 26*311d023aSAlex Crichton #undef wasm_engine_clone 271819edbaSAlex Crichton 281819edbaSAlex Crichton /// \brief Creates an engine with default compilation settings. Engine()291819edbaSAlex Crichton Engine() : ptr(wasm_engine_new()) {} 301819edbaSAlex Crichton /// \brief Creates an engine with the specified compilation settings. Engine(Config config)311819edbaSAlex Crichton explicit Engine(Config config) 32*311d023aSAlex Crichton : ptr(wasm_engine_new_with_config(config.capi_release())) {} 331819edbaSAlex Crichton 341819edbaSAlex Crichton /// \brief Increments the current epoch which may result in interrupting 351819edbaSAlex Crichton /// currently executing WebAssembly in connected stores if the epoch is now 361819edbaSAlex Crichton /// beyond the configured threshold. increment_epoch() const371819edbaSAlex Crichton void increment_epoch() const { wasmtime_engine_increment_epoch(ptr.get()); } 381819edbaSAlex Crichton 391819edbaSAlex Crichton /// \brief Returns whether this engine is using Pulley for execution. is_pulley() const401819edbaSAlex Crichton void is_pulley() const { wasmtime_engine_is_pulley(ptr.get()); } 411819edbaSAlex Crichton }; 421819edbaSAlex Crichton 431819edbaSAlex Crichton } // namespace wasmtime 441819edbaSAlex Crichton 451819edbaSAlex Crichton #endif // WASMTIME_ENGINE_HH 46