FirteX-高性能全文索引和检索平台

API Documentation


首页 | 名字空间列表 | 类继承关系 | 组合类型列表 | $(BL\录(B | 文件列表 | 名字空间成员 | 组合类型成员 | 文件成员

Thread.h

浏览该文件的文档。
00001 //
00002 // Copyright(C) 2005--2006 Institute of Computing Tech, Chinese Academy of Sciences. 
00003 // All rights reserved.
00004 // This file is part of FirteX (www.firtex.org)
00005 //
00006 // Use of the FirteX is subject to the terms of the software license set forth in 
00007 // the LICENSE file included with this software, and also available at
00008 // http://www.firtex.org/license.html
00009 //
00010 // Author       : 郭瑞杰(GuoRuijie)
00011 // Email        : ruijieguo@software.ict.ac.cn,ruijieguo@gmail.com
00012 // Created      : 2005/11/18
00013 //
00014 
00015 #ifndef _THREAD_LINUX_H
00016 #define _THREAD_LINUX_H
00017 
00018 #include <pthread.h>
00019 #include <assert.h>
00020 
00021 #include "thread/Runnalble.h"
00022 
00023 
00024 namespace firtex
00025 {
00026         namespace thread
00027         {
00028                 class CThread
00029                 {
00030                 public:
00031                         CThread() : m_tid(0)
00032                         {
00033                         }
00034                         ~CThread()
00035                         {
00036                         }               
00037 
00038                 protected:
00039                         static void* _dispatch(void *arg)
00040                         {
00041                                 CRunnalble* task = reinterpret_cast<CRunnalble*>(arg);
00042                                 assert(task);
00043 
00044                                 task->run();
00045 
00046                                 pthread_exit((void**)0);
00047                                 return (void*)0;
00048                         }
00049                 public:
00050                         bool spawn(CRunnalble* task) 
00051                         {
00052                                 return (pthread_create(&m_tid, 0, _dispatch, task) == 0);
00053                         }
00054 
00055                         void wait()
00056                         {
00057                                 //TODO:
00058                         }
00059                         
00060                 protected:
00061                         pthread_t m_tid;
00062                 private:
00063                 };
00064         }
00065 }
00066 
00067 
00068 #endif

http://www.firtex.org http://www.sourceforge.net/projects/firtex