Re: Releasing static variable & concurrent data protection questions...

2010-11-15 Thread Greg Guerin
Frederick C. Lee wrote: 2) Static variables on stack <-- I was aware of this. "Static" and "on stack" are mutually exclusive. It's impossible to have a variable that is both, so "static variables on stack" is nonsense. BTW, the C storage specifier for "on stack" is "auto". You might

Re: Releasing static variable & concurrent data protection questions...

2010-11-15 Thread Frederick C. Lee
Ultimate scenario: Predicting satellites... one...many. Each satellite is govern my Keplerian physics {drag,etc.}; so I'll be working with a dozen+ variables, in parallel/concurrently. Programming Scenario: a) Satellites' identifiers stored in Core Data. <--- Done. b) User select sele

Re: Releasing static variable & concurrent data protection questions...

2010-11-15 Thread Scott Ribe
On Nov 15, 2010, at 2:08 PM, Frederick C. Lee wrote: > This isn't 'real code'. > This is merely an attempt to learn GCD & concurrency: sharing common data, > etc. OK. > The reason for alloc a NSNumber is to work with the heap vs stack. > I'll also be working with C structures as well. static i

Re: Releasing static variable & concurrent data protection questions...

2010-11-15 Thread Frederick C. Lee
Thanks for the warning! Understood. Ric. On Nov 15, 2010, at 1:09 PM, Greg Parker wrote: > On Nov 15, 2010, at 1:08 PM, Frederick C. Lee wrote: >> I'll peek at OSAtomic.h >> >> I'm in a learning phase, so I'll expect to 'flutter about' before I can fly. > > In that case, do not peek at OSAtomic

Re: Releasing static variable & concurrent data protection questions...

2010-11-15 Thread Greg Parker
On Nov 15, 2010, at 1:08 PM, Frederick C. Lee wrote: > I'll peek at OSAtomic.h > > I'm in a learning phase, so I'll expect to 'flutter about' before I can fly. In that case, do not peek at OSAtomic.h. Avoid OSAtomic.h until you understand the basics of coordinating access to shared data. > BTW

Re: Releasing static variable & concurrent data protection questions...

2010-11-15 Thread Frederick C. Lee
This isn't 'real code'. This is merely an attempt to learn GCD & concurrency: sharing common data, etc. The reason for alloc a NSNumber is to work with the heap vs stack. I'll also be working with C structures as well. Yes, working with static int mynum is of course, much simpler. I'll peek at OS

Re: Releasing static variable & concurrent data protection questions...

2010-11-15 Thread Scott Ribe
On Nov 15, 2010, at 1:06 PM, Frederick C.Lee wrote: > 1) How do I properly release my static NSNumber *myNumber after use? Why would you want to? The point of a static is to last the lifetime of the application. However, your code as you posted it, is quite messed up. You create a number that

Releasing static variable & concurrent data protection questions...

2010-11-15 Thread Frederick C . Lee
Environment: OS X (10.6.5) & iOS4+... Scenario: I have a static object (myNumber) that I use to accumulate a value through multiple iterations from concurrent blocks. Here's what I have learned: 1) Best way to 'share' variables is via heap vs stack. Hence, I've created a static object 'myN