Re: Of input loops and games
Re: Of input loops and games
- Subject: Re: Of input loops and games
- From: Hari Seldon <email@hidden>
- Date: Wed, 21 Sep 2005 21:13:00 -0500
Jack, could I form a bronzed statue of you and worship it day and
night? Thanks to you, my new threads and autorelease pools are working
like a charm, and my nightmarish memory leaks are but a vague memory.
Thanks again!
On 9/21/05, Jack Nutting <email@hidden> wrote:
> Instead, you could use a static pointer in one of your recurring functions,
> perhaps modifying get_key_from_user() like this:
>
> int get_key_from_user()
> {
> static NSAutoreleasePool *pool = nil;
>
> // first time through, this just sends release to nil, which is OK
> [pool release];
> pool = [[NSAutoreleasePool alloc] init];
>
> // this blocks the thread until the main thread unlocks it
> [[c_controller keyLock] lock];
> return [c_controller getCurrentKeyAndClear];
> }
>
> The very first time get_key_from_user() is called, this will create a pool,
> and each subsequent time it will release the old pool and create a new one.
> This approach will end up doing a pool cleanup for each keypress, which is
> probably a pretty good granularity.
>
> --
>
> // jack
> // http://www.nuthole.com
_______________________________________________
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