Deadlock when using multiple OpenGLRenderer components as children of a non openGL component

I am in the process of implementing a single OpenGLContext based rendering system like the one described by @TonyAtHarrison. Tony, your description above is extremely helpful, but I have a question. You stated that to add/remove renderers at run-time, you had to create some kind of synchronization system since these requests would be run on the Message thread while the GL thread could also be accessing the renderer queues.

Is this synchronization unnecessary since the OpenGL thread holds a MessageManager::Lock while calling renderOpenGL?

There was a previous post I made asking if accessing Message thread data (Component width/height) in renderOpenGL() was a race condition, but I was told it was not because the GL thread holds a Message thread lock whenever it calls renderOpenGL():

From what I understand, if you were adding, removing, or re-ordering renderers at run-time from the message thread in a system as you describe, @TonyAtHarrison:

  • When adding a new renderer at runtime, you could call the renderer’s newOpenGLContextCreated() method and then immediately add it to the array of renderers.
  • When removing a renderer, call its openGLContextClosing() method and immediately remove it from the array of renderers
  • When re-ordering, you would simply just swap various positions in the array of renderers.
  • And all of this functionality could happen without needing any synchronization such as locks or atomic variables.

I may be completely misunderstanding this, but would love to know if my thinking here is wrong so I can correct my assumptions. Thanks for any help here!