From 85b6670c3b329269cf8924edf9151bcd345bfa12 Mon Sep 17 00:00:00 2001 From: Ofri Wolfus Date: Sun, 5 Aug 2007 14:55:36 +0300 Subject: [PATCH] Some fixes to DPCoroutineStack: * Set the coroutine's parent when it's added to the stack. No need to do it before starting. * Don't modify the current stack when processing. * Don't signal for active routines which will cause threads to loop for no reason. --- Source/DPCoroutine.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/DPCoroutine.m b/Source/DPCoroutine.m index 33c1c2d..8c938f5 100644 --- a/Source/DPCoroutine.m +++ b/Source/DPCoroutine.m @@ -239,6 +239,7 @@ static void __attribute__((constructor)) _DPSetupMainCoroStack(void) { OSSpinLockLock(&stackLock); [stack addObject:coro]; OSSpinLockUnlock(&stackLock); + [coro setParent:[self mainCoro]]; [self signal]; } @@ -256,11 +257,10 @@ static void __attribute__((constructor)) _DPSetupMainCoroStack(void) { [self retain]; [self signal]; - [coro setParent:[self mainCoro]]; if ([coro isActive]) { shouldContinue = [coro continue]; } else { - [DPCoroutineStack setCurrentStack:self]; + //[DPCoroutineStack setCurrentStack:self]; [coro start]; shouldContinue = [coro isActive]; } @@ -284,9 +284,9 @@ static void __attribute__((constructor)) _DPSetupMainCoroStack(void) { OSSpinLockUnlock(&stackLock); } - OSMemoryBarrier(); + /*OSMemoryBarrier(); if (activeRoutines > 0) - [self signal]; + [self signal];*/ return NO; } -- 2.11.4.GIT