alejzeis/mango-engine

Shared Structure

Closed this issue · 1 comments

Due to the nature of D, all mutable values are by default thread-local. The shared modifier makes a value available to all threads.

What would be the best structure to share the correct values across threads, so a concurrent multithreading event system can be implemented?

List of items that need to be shared:

  • Model
    • Textures
    • Shaders
  • GameManager
    • Window
    • Scene
      • Model's
      • Texture's
      • Shader's

The event system will most likely need to access these members, and modify them if possible across threads. Methods are encouraged to synchronized(SyncLock lock) code that accesses and modifies these variables.

Solved!

Current system will rely on private class variables prefixed with "_", these will be declared shared. An @Property method will return the variable casted to thread local. If this variable is a class then the whole system is repeated again in a chain.