• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Of input loops and games
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Of input loops and games


  • Subject: Re: Of input loops and games
  • From: Jack Nutting <email@hidden>
  • Date: Thu, 22 Sep 2005 01:16:33 +0200

On 9/22/05, Hari Seldon <email@hidden> wrote:
>
> Sadly, I don't have "control" over the start_move_loop function --
> it's built into the original C code. Is it possible to clear the pool
> on a timer, or would that raise problems?


You could use a timer of some sort, but that would end up creating and
releasing pools continuously, even if your game was just idling, waiting for
input.

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

  • Follow-Ups:
    • Re: Of input loops and games
      • From: Hari Seldon <email@hidden>
References: 
 >Of input loops and games (From: Hari Seldon <email@hidden>)
 >Re: Of input loops and games (From: Jack Nutting <email@hidden>)
 >Re: Of input loops and games (From: Hari Seldon <email@hidden>)
 >Re: Of input loops and games (From: Sherm Pendley <email@hidden>)
 >Re: Of input loops and games (From: Hari Seldon <email@hidden>)

  • Prev by Date: (no subject)
  • Next by Date: Bindings trouble.
  • Previous by thread: Re: Of input loops and games
  • Next by thread: Re: Of input loops and games
  • Index(es):
    • Date
    • Thread