Ignore:
Timestamp:
11/19/18 15:52:54 (5 years ago)
Author:
yushan
Message:

branch_openmp merged with trunk r1597

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_trunk_omp/src/log.hpp

    r523 r1601  
    55#include <iostream> 
    66#include <string> 
     7#include <stdio.h> 
     8#include <omp.h> 
    79 
    810namespace xios 
     
    1416    public : 
    1517    CLog(const string& name_, std::streambuf* sBuff = cout.rdbuf()) 
    16       : ostream(sBuff), level(0), name(name_), strBuf_(sBuff) {} 
    17     CLog& operator()(int l) 
     18      : ostream(sBuff), level(0), name(name_), strBuf_(sBuff)  
    1819    { 
    19       if (l<=level) 
    20       { 
    21         rdbuf(strBuf_); 
    22         *this<<"-> "<<name<<" : " ; 
    23       } 
    24       else rdbuf(NULL) ; 
    25       return *this; 
     20      omp_init_lock( &mutex ); 
     21      for(int i=0; i<16; i++) 
     22        strBuf_array[i] = sBuff; 
    2623    } 
     24 
     25    ~CLog() 
     26    { 
     27      omp_destroy_lock( &mutex ); 
     28    } 
     29 
     30    CLog& operator()(int l); 
    2731    void setLevel(int l) {level=l; } 
    2832    int getLevel() {return level ;} 
     
    4650     * \param [in] pointer to new streambuf 
    4751    */ 
    48     void changeStreamBuff(std::streambuf* sBuff) { strBuf_ = sBuff; rdbuf(sBuff); } 
     52    void changeStreamBuff(std::streambuf* sBuff)  
     53    {  
     54      strBuf_ = sBuff;  
     55      strBuf_array[omp_get_thread_num()] = sBuff; 
     56      rdbuf(sBuff); 
     57    } 
    4958 
    5059    int level ; 
    5160    string name ; 
    5261    std::streambuf* strBuf_; 
     62    std::streambuf* strBuf_array[16]; 
     63    omp_lock_t mutex; 
    5364  }; 
    5465 
     
    5667  extern CLog report; 
    5768  extern CLog error; 
     69 
     70  extern std::filebuf* info_FB[16]; 
    5871} 
    5972#endif 
Note: See TracChangeset for help on using the changeset viewer.