Skip to content

Class jac::MachineBase

ClassList > jac > MachineBase

Public Functions

Type Name
MachineBase () = default
MachineBase (const MachineBase &) = delete
MachineBase (MachineBase &&) = delete
ContextRef context ()
Get the ContextRef for this machine.
Value eval (std::string code, std::string filename, EvalFlags flags=EvalFlags::Global)
Evaluate a string containing javascript code.
void initialize ()
Initialize the machine. Should be called after machine configuration is done and before any interaction with the javascript engine. Other MFeatures in the Machine stack can implement this method to initialize themselves but the first call should be Next::initialize().
void interruptRuntime ()
Interrupt running javascript code. Execution will be thrown in the javascript as an InterruptError.
Module & newModule (std::string name)
Create a new module in the machine.
MachineBase & operator= (const MachineBase &) = delete
MachineBase & operator= (MachineBase &&) = delete
void resetWatchdog ()
Reset the watchdog timer. This should be called periodically to prevent the watchdog from triggering.
JSRuntime * runtime ()
Get the JSRuntime* for this machine.
void setWatchdogHandler (std::function< bool()> callback)
Set the watchdog callback. The callback will be called when the watchdog timeout has passed since the last reset. If the callback returns true, the runtime will be interrupted.
void setWatchdogTimeout (std::chrono::milliseconds timeout)
Set the watchdog timeout. If the timeout is zero, the watchdog is disabled. Otherwise, the watchdog will be called when the timeout has passed since the last reset.
virtual ~MachineBase ()

Public Functions Documentation

function MachineBase [1/3]

jac::MachineBase::MachineBase () = default

function MachineBase [2/3]

jac::MachineBase::MachineBase (
    const MachineBase &
) = delete

function MachineBase [3/3]

jac::MachineBase::MachineBase (
    MachineBase &&
) = delete

function context

Get the ContextRef for this machine.

inline ContextRef jac::MachineBase::context () 

Returns:

The ContextRef

function eval

Evaluate a string containing javascript code.

Value jac::MachineBase::eval (
    std::string code,
    std::string filename,
    EvalFlags flags=EvalFlags::Global
) 

Parameters:

  • code the code to evaluate
  • filename filename to use for the code. Used for error reporting
  • flags flags to evaluate the code with

Returns:

Result of the evaluation

function initialize

void jac::MachineBase::initialize () 

function interruptRuntime

inline void jac::MachineBase::interruptRuntime () 

function newModule

Create a new module in the machine.

Module & jac::MachineBase::newModule (
    std::string name
) 

Parameters:

  • name name of the module

Returns:

Reference to the new module

function operator=

MachineBase & jac::MachineBase::operator= (
    const MachineBase &
) = delete

function operator=

MachineBase & jac::MachineBase::operator= (
    MachineBase &&
) = delete

function resetWatchdog

inline void jac::MachineBase::resetWatchdog () 

function runtime

Get the JSRuntime* for this machine.

inline JSRuntime * jac::MachineBase::runtime () 

Returns:

The JSRuntime*

function setWatchdogHandler

Set the watchdog callback. The callback will be called when the watchdog timeout has passed since the last reset. If the callback returns true, the runtime will be interrupted.

inline void jac::MachineBase::setWatchdogHandler (
    std::function< bool()> callback
) 

Parameters:

  • callback callback to call

function setWatchdogTimeout

Set the watchdog timeout. If the timeout is zero, the watchdog is disabled. Otherwise, the watchdog will be called when the timeout has passed since the last reset.

inline void jac::MachineBase::setWatchdogTimeout (
    std::chrono::milliseconds timeout
) 

Parameters:

  • timeout watchdog timeout

function ~MachineBase

inline virtual jac::MachineBase::~MachineBase () 

Friends Documentation

friend Module

class jac::MachineBase::Module (
    Module
) 

The documentation for this class was generated from the following file src/jac/machine/machine.h