Poco::JS::Core

class TimedJSExecutor

File Information

Library: JS/Core
Package: Execution
Header: Poco/JS/Core/JSExecutor.h

Description

This class extends the basic JSExecutor class with a JSTimer-based event loop, allowing the definition of timers in JavaScript code.

Scripts can use the setTimeout() and setInterval() JavaScript functions to define timer-based callbacks.

Inheritance

Direct Base Classes: JSExecutor

All Base Classes: JSExecutor, Poco::RefCountedObject, Poco::Runnable

Known Derived Classes: Poco::OSP::JS::TimedJSExecutor

Member Summary

Member Functions: cancelTimer, handleOutOfMemory, run, schedule, setImmediate, setInterval, setTimeout, setupGlobalObjectTemplate, stop, timer

Inherited Functions: addModuleRegistry, addModuleSearchPath, attachToCurrentThread, buildStackTrace, call, callInContext, cancelTerminate, cleanup, compile, current, duplicate, globalContext, handleError, handleMemoryWarning, handleOutOfMemory, importModule, include, includeScript, isRunning, isTerminating, isolate, referenceCount, release, reportError, require, resolveModule, run, runImpl, scriptCompleted, scriptContext, setWrapperProperty, setup, setupGlobalObject, setupGlobalObjectTemplate, sleep, stop, terminate, uri

Types Aliases

Ptr

using Ptr = Poco::AutoPtr < TimedJSExecutor >;

Constructors

TimedJSExecutor

TimedJSExecutor(
    const std::string & source,
    const Poco::URI & sourceURI,
    const std::vector < std::string > & moduleSearchPaths,
    Poco::UInt64 memoryLimit = JSExecutor::DEFAULT_MEMORY_LIMIT
);

Creates the TimedJSExecutor.

Destructor

~TimedJSExecutor virtual

~TimedJSExecutor();

Destroys the TimedJSExecutor.

Member Functions

run virtual

void run();

Runs the script as timer task. Note that run() will return immediately. The script will be executed within the timer thread.

schedule

void schedule(
    Poco::Util::TimerTask::Ptr pTask
);

Schedules a task using the timer-based event loop.

schedule

void schedule(
    Poco::Util::TimerTask::Ptr pTask,
    const Poco::Clock & clock
);

Schedules a task using the timer-based event loop.

stop virtual

void stop();

Stops the executor and cancels all timer events.

cancelTimer protected static

static void cancelTimer(
    const v8::FunctionCallbackInfo < v8::Value > & args
);

handleOutOfMemory protected virtual

void handleOutOfMemory(
    std::size_t currentHeapLimit,
    std::size_t initialHeapLimit
);

setImmediate protected static

static void setImmediate(
    const v8::FunctionCallbackInfo < v8::Value > & args
);

setInterval protected static

static void setInterval(
    const v8::FunctionCallbackInfo < v8::Value > & args
);

setTimeout protected static

static void setTimeout(
    const v8::FunctionCallbackInfo < v8::Value > & args
);

setupGlobalObjectTemplate protected virtual

void setupGlobalObjectTemplate(
    v8::Local < v8::ObjectTemplate > & global,
    v8::Isolate * pIsolate
);

timer protected inline

JSTimer & timer();

Returns the executor's timer.

Securely control IoT edge devices from anywhere   Connect a Device