init.lua 1.5 KB

123456789101112131415161718192021222324252627282930
  1. return {
  2. tag = 'modules',
  3. summary = 'Allows the creation of background threads.',
  4. description = [[
  5. The `lovr.thread` module provides functions for creating threads and communicating between them.
  6. These are operating system level threads, which are different from Lua coroutines.
  7. Threads are useful for performing expensive background computation without affecting the
  8. framerate or performance of the main thread. Some examples of this include asset loading,
  9. networking and network requests, and physics simulation.
  10. Threads come with some caveats:
  11. - Threads run in a bare Lua environment. The `lovr` module (and any of lovr's modules) need to
  12. be required before they can be used.
  13. - Threads are completely isolated from other threads. They do not have access to the variables
  14. or functions of other threads, and communication between threads must be coordinated through
  15. `Channel` objects.
  16. - The graphics module (or any functions that perform rendering) cannot be used in a thread.
  17. Note that this includes creating graphics objects like Models and Textures. There are "data"
  18. equivalent `ModelData` and `TextureData` objects that can be used in threads though.
  19. - `lovr.event.pump` cannot be called from a thread.
  20. - Crashes or problems can happen if two threads access the same object at the same time, so
  21. special care must be taken to coordinate access to objects from multiple threads.
  22. ]],
  23. related = {
  24. 'lovr.system.getCoreCount'
  25. }
  26. }