Threading and Coroutines.
Exercises, examples and other material relating to training module U114. This topic is presented on public courses
Learning to program in Lua,
Lua Programming
| Articles and tips on this subject | updated |
| 3395 | Parallel but not really parallel. Moving game characters. Coroutines in Lua. Virtual World game programming involves moving many characters - both player controlled and automatic - in parallel. The movements of each character depend - to a greater or lesser extent - on the prior movements of the character, and of the other charcaters and the resultant position and condition that ... | 2011-08-18 |
| 2455 | Lua examples - coroutines, error handling, objects, etc I have presented a bespoke Lua course over the last three days ... and it has lead me to some interesting new examples which I'm sharing here.
Object Orientation is more a way of thinking and coding than a language feature in Lua - when you set up a piece of data / structure / object, you do so in a ... | 2009-10-17 |
| 2314 | Passing parameters to a coroutine in Lua Lua's coroutines, like Python's generators, provide for something which is akin to lightweight threading - rather than a strict functional calling stack, where one function must be completed before another is invoked, you can call a code block (function or method) and have it yield back to the calling ... | 2009-08-01 |
| 1870 | What to do with a huge crop of apples Last year, you had a good crop of apples on your tree .... what did you do with them? Make apple pies for all the neighbours! How?
• You collect all the apples and bring them into the kitchen.
• You prepare the apples ready for the pies.
• You make the pastry and apple pies.
• You ... | 2008-11-04 |
| 1699 | If you are learning Lua, here are some more examples During some courses, I write few (if any) new examples in front of my delegates, rather relying on the standard ones in the training notes (which I wrote anyway!) and making small changes and adjustments to illustrate how things work. On other courses, though, I write a some new examples from scratch ... | 2008-08-05 |
| 1691 | Co-routines in Lua - co-operative processing CoRoutines in Lua allow you to have a number of pieces of co-operative code which (whilst they’re not running in parallel in a true multithreaded way) allow you to progress through multiple strands of your code at the sametime.
Let’s take an example. I have a rather large text file that lists ... | 2008-06-29 |
1cab
Examples from our training material
| charmoves | coroutine for game player movements |
| coro | simple coroutine example |
| cosy | Illustration of Coroutines |
| crcr | coroutine basics |
| datafeeder | using a coroutine as a generator |
| ff2.lua | Multiple coroutines in parallel use |
| inco | Passing parameters to coroutines |
| nocoro | NOT using coroutines - filling a table then using it instead |
Background information
Some modules are
available for download as a sample of our material or under an
Open Training Notes License for free download from
http://www.training-notes.co.uk.
Topics covered in this module
Coroutines as co-operative programs.
Transferring control and maintaining state.
Concurrent tasks, and keeping them apart.
Event handling - event loops and yielding
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our
Listing and schedule page.
Well House Consultants specialise in training courses in
Python,
Perl,
PHP, and
MySQL. We run
Private Courses throughout the UK (and beyond for longer courses), and
Public Courses at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if
you live in a different
country or continent to us.
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre. Also
available is the Opentalk
Forum for discussion of technical questions.