Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-18976] iOS - Remove KrollThread #6891

Merged
merged 7 commits into from
Aug 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 4 additions & 10 deletions iphone/Classes/KrollBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -438,17 +438,10 @@ - (void)evalFileOnThread:(NSString*)path context:(KrollContext*)context_
}

const char *urlCString = [[url_ absoluteString] UTF8String];
TiStringRef jsCode = TiStringCreateWithCFString((CFStringRef) jcode);

TiStringRef jsCode = TiStringCreateWithCFString((CFStringRef) jcode);
TiStringRef jsURL = TiStringCreateWithUTF8CString(urlCString);

// TIMOB-18152. There is no need to check syntax since TiEvalScript
// will check syntax before evaluation of the script.
// if (![TI_APPLICATION_DEPLOYTYPE isEqualToString:@"production"]) {
// TiCheckScriptSyntax(jsContext,jsCode,jsURL,1,&exception);
// }

// only continue if we don't have any exceptions from above
if (exception == NULL) {
#ifndef USE_JSCORE_FRAMEWORK
if ([[self host] debugMode]) {
Expand All @@ -464,6 +457,8 @@ - (void)evalFileOnThread:(NSString*)path context:(KrollContext*)context_
#endif
if (exception == NULL) {
evaluationError = NO;
} else {
evaluationError = YES;
}
}
if (exception != NULL) {
Expand All @@ -474,7 +469,6 @@ - (void)evalFileOnThread:(NSString*)path context:(KrollContext*)context_

TiStringRelease(jsCode);
TiStringRelease(jsURL);

[pool release];
}

Expand Down
4 changes: 3 additions & 1 deletion iphone/Classes/KrollCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
TiObjectRef function;
KrollContext *context;
KrollBridge * bridge;
NSLock* contextLock;
#ifdef TI_USE_KROLL_THREAD
NSLock* contextLock;
#endif
NSString *type;
}

Expand Down
26 changes: 20 additions & 6 deletions iphone/Classes/KrollCallback.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ -(id)initWithCallback:(TiValueRef)function_ thisObject:(TiObjectRef)thisObject_
thisObj = thisObject_;
TiValueProtect(jsContext, function);
TiValueProtect(jsContext, thisObj);
contextLock = [[NSLock alloc] init];
#ifdef TI_USE_KROLL_THREAD
contextLock = [[NSLock alloc] init];
#endif
[callbacks addObject:self];
}
return self;
Expand All @@ -67,7 +69,9 @@ -(void)dealloc
[callbackLock unlock];

[type release];
[contextLock release];
#ifdef TI_USE_KROLL_THREAD
[contextLock release];
#endif
if ([KrollBridge krollBridgeExists:bridge])
{
if ([context isKJSThread])
Expand Down Expand Up @@ -112,10 +116,14 @@ - (BOOL)isEqual:(id)anObject

-(id)call:(NSArray*)args thisObject:(id)thisObject_
{
#ifdef TI_USE_KROLL_THREAD
[contextLock lock];
#endif
if (context==nil)
{
[contextLock unlock];
#ifdef TI_USE_KROLL_THREAD
[contextLock unlock];
#endif
return nil;
}

Expand Down Expand Up @@ -156,7 +164,9 @@ -(id)call:(NSArray*)args thisObject:(id)thisObject_

id val = [KrollObject toID:context value:retVal];
[context release];
[contextLock unlock];
#ifdef TI_USE_KROLL_THREAD
[contextLock unlock];
#endif
return val;
}

Expand All @@ -172,9 +182,13 @@ -(KrollContext*)context

-(void)setContext:(KrollContext*)context_
{
[contextLock lock];
#ifdef TI_USE_KROLL_THREAD
[contextLock lock];
#endif
context = context_;
[contextLock unlock];
#ifdef TI_USE_KROLL_THREAD
[contextLock unlock];
#endif
}

@end
Expand Down
21 changes: 14 additions & 7 deletions iphone/Classes/KrollContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
{
@private
id<KrollDelegate> delegate;
NSString *contextId;
NSRecursiveLock *lock;
NSCondition *condition;
NSMutableArray *queue;
BOOL stopped;

//Garbage collection variables.
Expand All @@ -43,14 +39,21 @@
BOOL suspended;
TiGlobalContextRef context;
NSMutableDictionary *timers;
NSRecursiveLock *timerLock;
void *debugger;

#ifdef TI_USE_KROLL_THREAD
NSRecursiveLock *timerLock;
NSString *contextId;
NSRecursiveLock *lock;
NSCondition *condition;
NSMutableArray *queue;
id cachedThreadId;
#endif

}

@property(nonatomic,readwrite,assign) id<KrollDelegate> delegate;

-(NSString*)contextId;
-(void)start;
-(void)stop;
-(BOOL)running;
Expand All @@ -61,8 +64,10 @@

#ifdef DEBUG
// used during debugging only
#ifdef TI_USE_KROLL_THREAD
-(NSUInteger)queueCount;
#endif
#endif

-(void)invokeOnThread:(id)callback_ method:(SEL)method_ withObject:(id)obj condition:(NSCondition*)condition_;
-(void)invokeOnThread:(id)callback_ method:(SEL)method_ withObject:(id)obj callback:(id)callback selector:(SEL)selector_;
Expand All @@ -78,8 +83,10 @@
-(void)unregisterTimer:(double)timerId;

-(int)forceGarbageCollectNow;
#ifdef TI_USE_KROLL_THREAD
-(NSString*)contextId;
-(NSString*)threadName;

#endif
@end

//====================================================================================================================
Expand Down