Go to Post I looked at it and originally thought it was a crazy idea... then I looked at it again and it still sounds like a crazy idea. But crazy ideas tend to produce some excellent results. - Yipyapper [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #13   Spotlight this post!  
Unread 08-01-2014, 12:35
omalleyj omalleyj is offline
Registered User
AKA: Jim O'Malley
FRC #1279 (Cold Fusion)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2008
Location: New Jersey
Posts: 132
omalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to behold
Re: How to make timed sequences in java?

Quote:
Originally Posted by Ether View Post
Your "polling" code (a form of state machine as shown) runs once every 20ms yes? While you're waiting for the 2 seconds to elapse, you're doing one simple conditional jump every 20ms.

If CPU usage becomes a problem using this approach, there's probably something seriously wrong elsewhere in the code.


Agreed as stated. The Simple robot code is called once and your own loop runs as often as it can, the Iterative I believe is triggered by packet arrival at 20ms intervals (not in a position to verify at the moment).
I was addressing the more general case. I program microcontrollers where the loop is all yours. In FIRST need there are constraints. I try to teach the generic case (as a statemachine) and mention the FIRSTisms that impact it.
If programming a PIC or similar I would use a timer interupt and be more efficient than either by miles.
Didn't mean to start a debate, just to acknowledge that polling can sometimes be unnecessarily expensive, (and might be compared to a thread whose only instruction was sleep(2000), but I've never profiled either situation), but this was a case where simplicity was probably the best.

Last edited by omalleyj : 08-01-2014 at 12:37. Reason: can't spell
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 22:47.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi