⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 descriptors.c

📁 用c++包装好的线程库,直接拿来使用,提高效率.
💻 C
字号:
//// Copyright (C) 2000 Orn E. Hansen//// A C++ implementation of threaded IO.//#include "io.h"namespace cpp_threads {  DescriptorSet::DescriptorSet()  {    zero();  }  DescriptorSet::~DescriptorSet()  {  }  void  DescriptorSet::zero()  {    clear();    FD_ZERO(&_set);  }  void  DescriptorSet::add(Socket* ref_p)  {    Pthread::debug("adding descriptor %d",(int)*ref_p);    FD_SET( (int)*ref_p,&_set );    push_back(ref_p);  }  void  DescriptorSet::del(Socket& ref_p)  {    iterator i;    for( i=begin();i != end();i++ )      if( *(*i) == ref_p )	break;    if( i != end() ) {      Pthread::debug("removing %d",(int)(*(*i)));      FD_CLR( (int)*(*i),&_set );      remove( (*i) );    }  }  bool  DescriptorSet::isSet(Socket& ref_p)  {    if( FD_ISSET((int)ref_p,&_set) )      return true;    return false;  }  DescriptorSet::operator fd_set *()  {    return &_set;  }  DescriptorSet::operator fd_set()  {    return _set;  }  DescriptorSet&  DescriptorSet::operator =(DescriptorSet& ref_p)  {    iterator i;    clear();    _set = ref_p;    for( i=ref_p.begin();i != ref_p.end();i++ ) {      Pthread::debug("fd %d - %s",(int)(*(*i)),		     (FD_ISSET(*(*i),&_set)?"set":"clear"));      push_back( (*i) );    }    return *this;  }}; // Namespace

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -