I have a Scala/Java OpenGL application in which I use the Akka framework. At the moment, my OpenGL thread is independent from the actor system so I can guarantee calls to OpenGL functions always come from a single thread. This is important, otherwise OpenGL will complain.
Until now, I had to send messages from the OpenGL thread to actors in the system and this works pretty well. I am now faced with the need to send messages the other way around, but of course I cannot simply put the OpenGL in an actor as this will break the requirement that it runs from a single thread.
An alternative would be to use a queue and a lock manually for the communication between actors and the OpenGL thread, but I'd like to know if there's a way to place OpenGL calls in a special Actor that would be given a guarantee by Akka to run in a single thread.
Regards
You can use a single thread per actor using a
PinnedDispatcher
. According to the doc: