Difference between revisions of "4/Threading"
From Worms Knowledge Base
CyberShadow (Talk | contribs) (fibers?) |
CyberShadow (Talk | contribs) (One True Event Loop) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{ParentArticle|[[4]]}} | {{ParentArticle|[[4]]}} | ||
− | === | + | === Threading === |
+ | |||
* Having the game engine run in its own thread is a huge plus by itself. Game lag won't have to also mean UI lag. | * Having the game engine run in its own thread is a huge plus by itself. Game lag won't have to also mean UI lag. | ||
− | |||
* Combining SDL and network event loops in a single thread would be complicated. | * Combining SDL and network event loops in a single thread would be complicated. | ||
+ | * Fibers would solve synchronization and modality problems, unfortunately they are not very portable and not currently implemented in D. (It's still possible to use them using OS primitives.) | ||
+ | {{gap}} | ||
+ | * Use a single thread for event handling. Long-running synchronous tasks (such as the game engine) will run in separate threads. | ||
+ | * SDL and network event loops run in separate threads, sending messages to event handling thread? | ||
+ | ** How does the network thread handle ''sent'' data? | ||
+ | ** Is this a good idea for single-core CPUs? | ||
+ | |||
+ | === Modality === | ||
+ | |||
+ | ''Here, "modal" means "the call to show this dialog is blocking, and the calling code will resume running only after said dialog is closed". Confirmation message boxes are an example.'' | ||
+ | |||
+ | * Modal dialogs will not be used. | ||
+ | ** Not using modal dialogs isn't so bad in D, considering that it supports anonymous functions (lambdas). The code could look something like: <br><code>MessageBox("Are you sure you want to overwrite "~fileName~"?", (MessageBoxResult r) { if (r == MessageBoxResult.OK) saveFile(fileName); } );</code> | ||
+ | |||
+ | === Display list === | ||
+ | |||
+ | * Constructing the display list is a fairly cheap operation. The game engine should construct its display list (or meta-display list, since some visual elements do not depend on game logic) after every logic frame. | ||
+ | ** Tweened rendering..? | ||
− | == | + | == External links == |
− | * | + | * [http://gamedev.stackexchange.com/questions/8765/one-true-event-loop One True Event Loop] on Game Development StackExchange |
− | + | ||
− | + | ||
− | + |
Latest revision as of 17:30, 8 March 2011
(Up to 4)
Threading
- Having the game engine run in its own thread is a huge plus by itself. Game lag won't have to also mean UI lag.
- Combining SDL and network event loops in a single thread would be complicated.
- Fibers would solve synchronization and modality problems, unfortunately they are not very portable and not currently implemented in D. (It's still possible to use them using OS primitives.)
- Use a single thread for event handling. Long-running synchronous tasks (such as the game engine) will run in separate threads.
- SDL and network event loops run in separate threads, sending messages to event handling thread?
- How does the network thread handle sent data?
- Is this a good idea for single-core CPUs?
Modality
Here, "modal" means "the call to show this dialog is blocking, and the calling code will resume running only after said dialog is closed". Confirmation message boxes are an example.
- Modal dialogs will not be used.
- Not using modal dialogs isn't so bad in D, considering that it supports anonymous functions (lambdas). The code could look something like:
MessageBox("Are you sure you want to overwrite "~fileName~"?", (MessageBoxResult r) { if (r == MessageBoxResult.OK) saveFile(fileName); } );
- Not using modal dialogs isn't so bad in D, considering that it supports anonymous functions (lambdas). The code could look something like:
Display list
- Constructing the display list is a fairly cheap operation. The game engine should construct its display list (or meta-display list, since some visual elements do not depend on game logic) after every logic frame.
- Tweened rendering..?
External links
- One True Event Loop on Game Development StackExchange