Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2000:
[Freeciv-Dev] myusleep implementation
Home

[Freeciv-Dev] myusleep implementation

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] myusleep implementation
From: Jeff Mallatt <jjm@xxxxxxxxxxxx>
Date: Tue, 04 Jan 2000 10:15:40 -0500

While looking into smooth unit moves, I looked at myusleep():

void myusleep(unsigned long usec)
{
#ifdef HAVE_USLEEP
  usleep(usec);
#else
#ifdef HAVE_SNOOZE              /* BeOS */
  snooze(usec);
#else
#ifdef GENERATING_MAC
  EventRecord the_event;  /* dummy var for timesharing */
  WaitNextEvent(0, &the_event, GetCaretTime(), nil); /* this is suposed to
     give other application processor time for the mac */
#else
  struct timeval tv;

  tv.tv_sec=0;
  tv.tv_usec=100;
  select(0, NULL, NULL, NULL, &tv);
#endif
#endif
#endif
}

Which looks fine for the first two configurations, but doesn't seem to be using 
the 'usec' argument for either the MAC or default cases.  Am I missing 
something?

For the default, shouldn't "tv.tv_usec=100;" be "tv.tv_usec=usec;"?

And, for the MAC, we might do something like:

  EventRecord the_event;
  usec /= 16666;  /* microseconds to 1/60th seconds */
  if (!usec) usec = 1;
  WaitNextEvent(0, &the_event, usec, nil);

jjm


[Prev in Thread] Current Thread [Next in Thread]