Re: Multiple problems caused by changing NSThread sleepUntilDate interval
Re: Multiple problems caused by changing NSThread sleepUntilDate interval
- Subject: Re: Multiple problems caused by changing NSThread sleepUntilDate interval
- From: Pete Yandell <email@hidden>
- Date: Mon, 2 Feb 2004 14:24:34 +1100
Mike,
Your crashing problem is because you're using the variable pt in two
different threads without any sort of locking.
pt is created, destroyed and updated in the keyDown: method of your
main thread, but you use it to do transformations in your worker
thread. It's only a matter of time before pt is in the middle of being
modified when you try to use it, hence the crash. A simple run in the
debugger shows that the seg fault occurs when you're doing [pPaddle
transformUsingAffineTransform:pt] in the worker thread.
I'm betting the bounds issue is also related. You do weird things with
the relationship between pt and pPaddle in the two threads.
You need to go and read some more about threads and locking!
Pete Yandell
http://pete.yandell.com/
On 02/02/2004, at 1:34 PM, Mike Brinkman wrote:
>
I'm having several problems with a game I'm writing in Cocoa, none of
>
which
>
seemed to happen until I changed the time interval in my NSThread.
>
>
Right now, I'm using
>
>
[NSThread sleepUntilDate:[NSDate
>
dateWithTimeIntervalSinceNow:0.02]];
>
>
And I'm getting Signal 10 & Signal 11 errors. I don't experience them
>
when
>
the interval is greater than 0.02.
>
>
Also, a problem is occurring with my collision detection for the player
>
paddle. It wasn't able to go through the bounds of the view until I
>
changed
>
the time interval.
>
>
Finally, for whatever reason, my NSTextViews for the player & computer
>
scores don't get updated properly. I call
>
>
[pScoreField setIntValue:++pScore];
>
>
The score increases, but it's like the numbers overwrite the previous
>
score,
>
so that the score will have 1 superimposed over the 0. Sometimes it
>
happens,
>
sometimes it doesn't.
>
>
If anybody could please check out my code & tell me what the deal is, I
>
would really be grateful. The code can be downloaded at:
>
>
http://www.msu.edu/~brinkma1/xPong.sitx
>
>
Sorry to bother everybody, but I'm really having quite a bit of
>
trouble.
>
Ordinarily I would post this kind of request at iDevGames, but they
>
don't
>
seem to be up right now.
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.