Oolite
Loading...
Searching...
No Matches
OOJSEngineTimeManagement.h File Reference
Include dependency graph for OOJSEngineTimeManagement.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define OOJSStartTimeLimiter()
#define OOJSStartTimeLimiterWithTimeLimit(limit)
#define OOJSStopTimeLimiter()
#define kOOJSLongTimeLimit   (5.0)

Functions

void OOJSStartTimeLimiterWithTimeLimit_ (OOTimeDelta limit, const char *file, unsigned line)
void OOJSStopTimeLimiter_ (const char *file, unsigned line)
void OOJSTimeManagementInit (OOJavaScriptEngine *engine, JSRuntime *runtime)

Macro Definition Documentation

◆ kOOJSLongTimeLimit

#define kOOJSLongTimeLimit   (5.0)

◆ OOJSStartTimeLimiter

◆ OOJSStartTimeLimiterWithTimeLimit

#define OOJSStartTimeLimiterWithTimeLimit ( limit)

◆ OOJSStopTimeLimiter

Function Documentation

◆ OOJSStartTimeLimiterWithTimeLimit_()

void OOJSStartTimeLimiterWithTimeLimit_ ( OOTimeDelta limit,
const char * file,
unsigned line )

Definition at line 80 of file OOJSEngineTimeManagement.m.

84{
85#if OOJS_DEBUG_LIMITER
86 OOLog(@"script.javaScript.timeLimit.debug", @"Limiter starting: %u => %u", sLimiterStartDepth, sLimiterStartDepth + 1);
87#endif
88 if (sLimiterStartDepth++ == 0) {
89 if (limit <= 0.0)
90 limit = OOJS_TIME_LIMIT;
91 sLimiterTimeLimit = limit;
93
96 }
97
98#ifndef NDEBUG
99 sLastStartedFile = file;
100 sLastStartedLine = line;
101#endif
102}
#define OOJS_TIME_LIMIT
static const char * sLastStartedFile
static double sLimiterTimeLimit
static int sLimiterPauseDepth
static unsigned sLimiterStartDepth
static OOHighResTimeValue sLimiterStart
static unsigned sLastStartedLine
#define OOLog(class, format,...)
Definition OOLogging.h:84
#define OOGetHighResTime
#define OODisposeHighResTime(time)

References OODisposeHighResTime, OOGetHighResTime, OOJS_TIME_LIMIT, OOLog, sLastStartedFile, sLastStartedLine, sLimiterPauseDepth, sLimiterStart, sLimiterStartDepth, and sLimiterTimeLimit.

◆ OOJSStopTimeLimiter_()

void OOJSStopTimeLimiter_ ( const char * file,
unsigned line )

Definition at line 105 of file OOJSEngineTimeManagement.m.

109{
110#ifndef NDEBUG
111 if (sLimiterStartDepth == 0) {
112 OOLog(@"bug.javaScript.limiterDepth", @"Attempt to stop JavaScript time limiter while it is already fully stopped. This is an internal bug, please report it. (Last start: %@:%u, last valid stop: %@:%u, this stop attempt: %@:%u.)", OOLogAbbreviatedFileName(sLastStartedFile), sLastStartedLine, OOLogAbbreviatedFileName(sLastStoppedFile), sLastStoppedLine, OOLogAbbreviatedFileName(file), line);
113 return;
114 }
115
116 sLastStoppedFile = file;
117 sLastStoppedLine = line;
118
119#if OOJS_DEBUG_LIMITER
120 OOLog(@"script.javaScript.timeLimit.debug", @"Limiter ending: %u <= %u", sLimiterStartDepth - 1, sLimiterStartDepth);
121#endif
122
123#endif
124
125 if (--sLimiterStartDepth == 0)
126 sLimiterTimeLimit = 0.0;
127}
static unsigned sLastStoppedLine
static const char * sLastStoppedFile
NSString * OOLogAbbreviatedFileName(const char *inName)
Definition OOLogging.m:762

References OOLog, OOLogAbbreviatedFileName(), sLastStartedFile, sLastStartedLine, sLastStoppedFile, sLastStoppedLine, sLimiterStartDepth, and sLimiterTimeLimit.

Here is the call graph for this function:

◆ OOJSTimeManagementInit()

void OOJSTimeManagementInit ( OOJavaScriptEngine * engine,
JSRuntime * runtime )

Definition at line 240 of file OOJSEngineTimeManagement.m.

241{
242 [NSThread detachNewThreadSelector:@selector(watchdogTimerThread)
243 toTarget:engine
244 withObject:nil];
245
246 JS_SetContextCallback(runtime, ContextCallback);
247}
static JSBool ContextCallback(JSContext *context, uintN contextOp)
return nil

References ContextCallback().

Referenced by OOJavaScriptEngine::init.

Here is the call graph for this function:
Here is the caller graph for this function: