Ork: a new object-oriented API on top of OpenGL

Started by
8 comments, last by sylvestre 13 years, 6 months ago
Quote:Original post by samoth
As a little criticism, I noticed that pretty much everything in your library derives from Object, which is a thread-safe reference counted base class.

Which, in general, is probably a good thing, but here I think it can become somewhat awkward.

If something is reference counted, then the "smartness" built into the class will clean up behind you, which is good. If something is threadsafe, it won't crash and burn when used in multithreaded programs, which is good.

However, if something is threadsafe, people will be tempted to use it in multiple threads, too. After all, it was explicitly made threadsafe!


in fact the main aspect is the reference counting; the thread safety is only provided for the taskgraph framework, where *CPU* tasks can be executed in parallel, while *GPU* tasks (i.e. all the tasks using the 'render' classes) are *forced* to be executed by a single dedicated thread.

Also note that some 'render' classes internally use some shared data structures which are *not* protected with mutexes, and so are *not* thread safe. This is normal, as these clases are supposed to be used in a single thread (and the MultithreadScheduler in 'taskgraph' enforces this)

Finally, note that you can disable the thread safety of the smart pointers in Atomic.h with the SINGLE_THREAD compiler flag.

This topic is closed to new replies.

Advertisement