Skip to main content
added 193 characters in body
Source Link
Engineer
  • 30.4k
  • 4
  • 76
  • 124

Is real-time usually modelled as just a really quick loop, or a thread with interrupt and sleep / wait / join?

Good that you edited to add this since I cast my eye over this 10 hours ago, because this is at the core of your question. Since we're otherwise unaware of your requirements, it isn't immediately clear whether you suggested threading for any pressing purpose.

The answer should always be a really quick loop until you get to the point where that can no longer do the job. There is always a price paid in complexity and opacity when using threads.

To make steady progress and properly understand how things should work when threaded, set it up to run on a single thread first, then, if required after standard optimisations, go multi-threaded. This was how I got started with threading in Java; if I hadn't, it would have taken probably double the time to get things right given complexity of the base functionality (dynamic mesh construction) running in a single thread. For AI, similarly - don't complicate things more than necessary right now.

YAGNI - you ain't gonna need it.

Is real-time usually modelled as just a really quick loop, or a thread with interrupt and sleep / wait / join?

Good that you edited to add this since I cast my eye over this 10 hours ago, because this is at the core of your question. Since we're otherwise unaware of your requirements, it isn't immediately clear whether you suggested threading for any pressing purpose.

To make steady progress and properly understand how things should work when threaded, set it up to run on a single thread first, then, if required after standard optimisations, go multi-threaded. This was how I got started with threading in Java; if I hadn't, it would have taken probably double the time to get things right given complexity of the base functionality (dynamic mesh construction) running in a single thread. For AI, similarly - don't complicate things more than necessary right now.

YAGNI - you ain't gonna need it.

Is real-time usually modelled as just a really quick loop, or a thread with interrupt and sleep / wait / join?

Good that you edited to add this since I cast my eye over this 10 hours ago, because this is at the core of your question. Since we're otherwise unaware of your requirements, it isn't immediately clear whether you suggested threading for any pressing purpose.

The answer should always be a really quick loop until you get to the point where that can no longer do the job. There is always a price paid in complexity and opacity when using threads.

To make steady progress and properly understand how things should work when threaded, set it up to run on a single thread first, then, if required after standard optimisations, go multi-threaded. This was how I got started with threading in Java; if I hadn't, it would have taken probably double the time to get things right given complexity of the base functionality (dynamic mesh construction) running in a single thread. For AI, similarly - don't complicate things more than necessary right now.

YAGNI - you ain't gonna need it.

Source Link
Engineer
  • 30.4k
  • 4
  • 76
  • 124

Is real-time usually modelled as just a really quick loop, or a thread with interrupt and sleep / wait / join?

Good that you edited to add this since I cast my eye over this 10 hours ago, because this is at the core of your question. Since we're otherwise unaware of your requirements, it isn't immediately clear whether you suggested threading for any pressing purpose.

To make steady progress and properly understand how things should work when threaded, set it up to run on a single thread first, then, if required after standard optimisations, go multi-threaded. This was how I got started with threading in Java; if I hadn't, it would have taken probably double the time to get things right given complexity of the base functionality (dynamic mesh construction) running in a single thread. For AI, similarly - don't complicate things more than necessary right now.

YAGNI - you ain't gonna need it.