Ogre1.7的多线程分析

在OgreConfig.h文件中有关于Ogre使用多线程的配置 

1. 多线程支持的级别 
/** Support for multithreading, there are 3 options 

OGRE_THREAD_SUPPORT = 0 
    No support for threading.        
OGRE_THREAD_SUPPORT = 1 
    Thread support for background loading, by both loading and constructing resources 
    in a background thread. Resource management and SharedPtr handling becomes 
    thread-safe, and resources may be completely loaded in the background. 
    The places where threading is available are clearly 
    marked, you should assume state is NOT thread safe unless otherwise 
    stated in relation to this flag. 
OGRE_THREAD_SUPPORT = 2 
    Thread support for background resource preparation. This means that resource 
    data can streamed into memory in the background, but the final resource 
    construction (including RenderSystem dependencies) is still done in the primary 
    thread. Has a lower synchronisation primitive overhead than full threading 
    while still allowing the major blocking aspects of resource management (I/O) 
    to be done in the background. 
*/ 
#ifndef OGRE_THREAD_SUPPORT 
#define OGRE_THREAD_SUPPORT 0 
#endif 
#if 
OGRE_THREAD_SUPPORT!= 0 && OGRE_THREAD_SUPPORT!= 1 && OGRE_THREAD_SUPPORT!= 2 
#define OGRE_THREAD_SUPPORT 0 
#endif 

2.支持多线程库的thread lib来源 
/** Provider for threading functionality, there are 4 options. 

OGRE_THREAD_PROVIDER = 0 
    No support for threading. 
OGRE_THREAD_PROVIDER = 1 
    Boost libraries provide threading functionality. 
OGRE_THREAD_PROVIDER = 2 
    Poco libraries provide threading functionality. 
OGRE_THREAD_PROVIDER = 3 
    TBB library provides threading functionality. 
*/ 
#ifndefOGRE_THREAD_PROVIDER 
#define OGRE_THREAD_PROVIDER 0 
#endif 

2.1 一个是boost提供的线程库 
2.2 一个是Poco libraries
 
POCO C++ Libraries 提供一套 C++ 的类库用以开发基于网络的可移植的应用程序,功能涉及线程、线程同步、文件系统访问、流操作、共享库和类加载、套接字以及网络协议包括:HTTP、FTP、SMTP 等;其本身还包含一个 HTTP 服务器,提供 XML 的解析和 SQL 数据库的访问接口。 
http://www.google.com.hk/search?hl=zh-CN&source=hp&biw=1241&bih=575&q=Poco+libraries&aq=f&aqi=&aql=&oq= 
2.3 TBB library 
http://threadingbuildingblocks.org/ 
Intel® Threading Building Blocks (Intel TBB) offers a rich and complete approach to expressing parallelism in a C++ program. It is a library that helps you take advantage of multi-core processor performance without having to be a threading expert. Intel TBB is not just a threads-replacement library. It represents a higher-level, task-based parallelism that abstracts platform details and threading mechanisms for scalability and performance.  

3.Ogre多线程的初始化 
在OgreMain中搜索OGRE_THREAD_SUPPORT得出以下文件清单 

Ogre1.7的多线程分析_第1张图片

3.1分析OgreRoot.cpp中有关OGRE_THREAD_SUPPORT的代码: 


上文来自:http://blog.csdn.net/butwang/article/details/6219424

你可能感兴趣的:(多线程,C++,C++11,OGRE)