Show
Ignore:
Timestamp:
08/27/08 22:02:39 (4 months ago)
Author:
frsyuki
Message:

lang/c/mpio: added mp::multiplex

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/c/mpio/trunk/mp/pthread.h

    r18310 r18340  
    2323 
    2424namespace mp { 
     25 
     26 
     27template <typename IMPL> 
     28class pthread_thread { 
     29public: 
     30        pthread_thread(IMPL* pimpl); 
     31        virtual ~pthread_thread(); 
     32private: 
     33        pthread_t m_thread; 
     34        static void* trampoline(void* obj); 
     35private: 
     36        pthread_thread(); 
     37        pthread_thread(const pthread_thread&); 
     38}; 
     39 
     40 
     41template <typename IMPL> 
     42pthread_thread<IMPL>::pthread_thread(IMPL* pimpl) 
     43{ 
     44        pthread_create(&m_thread, NULL, 
     45                        &pthread_thread<IMPL>::trampoline, 
     46                        reinterpret_cast<void*>(pimpl)); 
     47} 
     48 
     49template <typename IMPL> 
     50pthread_thread<IMPL>::~pthread_thread() {}  // FIXME 
     51 
     52template <typename IMPL> 
     53void* pthread_thread<IMPL>::trampoline(void* obj) 
     54{ 
     55        // FIXME exception 
     56        reinterpret_cast<IMPL*>(obj)->operator()(); 
     57        return NULL; 
     58} 
    2559 
    2660