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
~TimedJSExecutor();
Destroys the TimedJSExecutor.
Member Functions
run
void run();
Runs the script as timer task. Note that run() will return immediately. The script will be executed within the timer thread.
See also: Poco::JS::Core::JSExecutor::run()
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
void stop();
Stops the executor and cancels all timer events.
See also: Poco::JS::Core::JSExecutor::stop()
cancelTimer
static void cancelTimer(
const v8::FunctionCallbackInfo < v8::Value > & args
);
handleOutOfMemory
void handleOutOfMemory(
std::size_t currentHeapLimit,
std::size_t initialHeapLimit
);
setImmediate
static void setImmediate(
const v8::FunctionCallbackInfo < v8::Value > & args
);
setInterval
static void setInterval(
const v8::FunctionCallbackInfo < v8::Value > & args
);
setTimeout
static void setTimeout(
const v8::FunctionCallbackInfo < v8::Value > & args
);
setupGlobalObjectTemplate
void setupGlobalObjectTemplate(
v8::Local < v8::ObjectTemplate > & global,
v8::Isolate * pIsolate
);
timer
JSTimer & timer();
Returns the executor's timer.