Re: Variable looses it's value
Re: Variable looses it's value
- Subject: Re: Variable looses it's value
- From: Jiri Volejnik <email@hidden>
- Date: Thu, 16 Dec 2004 13:29:36 +0100
Without looking at the code it's hard to say.
Anyway, at least you should guard the counter with a lock.
I would also suggest using lock conditions instead of "sleepy polling",
but it's not related to the problem with the counter.
http://developer.apple.com/documentation/Cocoa/Conceptual/
Multithreading/Tasks/usinglocks.html
http://developer.apple.com/documentation/Cocoa/Conceptual/
Multithreading/index.html
Jirka.
On Dec 16, 2004, at 13:07, Peter Karlsson wrote:
Dear list!
My variable is declared like this in my controller.h file:
int sysexcounter;
When I click on a button a new thread is started and I reset the
variable:
sysexcounter = 0;
Then in my MyReadProc code it's increased every time I receive a midi
byte:
sysexcounter+=1;
And in the new thread I use this code to stop the flow until all bytes
have
been received.
while(sysexcounter < dumpSize)
{
usleep(1000000); // microseconds
}
This works sometimes and sometimes not. I have not seen any pattern at
all.
The problem is that my variable sysexcounter is sometimes 0 in my while
loop and it will continue looping forever. The variable sysexcounter
seems
to loose it's value, can someone please tell me why?
Best regards Peter
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden