当前位置: 首页>>代码示例>>C++>>正文


C++ THROW_RUNTIME_ERROR函数代码示例

本文整理汇总了C++中THROW_RUNTIME_ERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ THROW_RUNTIME_ERROR函数的具体用法?C++ THROW_RUNTIME_ERROR怎么用?C++ THROW_RUNTIME_ERROR使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了THROW_RUNTIME_ERROR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: read

    void read(socket_t hsock_i, void* data_i, size_t bytes)
    {
#if BUFFERING
      char* data = (char*)data_i;
      buffered_socket_t* hsock = (buffered_socket_t*) hsock_i;
      while (bytes) {
        if (hsock->istart == hsock->iend) {
          ssize_t n = ::recv(hsock->fd,hsock->ibuf,hsock->isize,MSG_NOSIGNAL);
          if      (n == 0) throw Disconnect();
          else if (n  < 0) THROW_RUNTIME_ERROR("error reading from socket");
          hsock->istart = 0;
          hsock->iend = n;
        }
        size_t bsize = hsock->iend-hsock->istart;
        if (bytes < bsize) bsize = bytes;
        memcpy(data,hsock->ibuf+hsock->istart,bsize);
        data += bsize;
        hsock->istart += bsize;
        bytes -= bsize;
      }
#else
      char* data = (char*) data_i;
      buffered_socket_t* hsock = (buffered_socket_t*) hsock_i;
      while (bytes) {
        ssize_t n = ::read(hsock->fd,data,bytes);
        if      (n == 0) throw Disconnect();
        else if (n  < 0) THROW_RUNTIME_ERROR("error reading from socket");
        data+=n;
        bytes-=n;
      }
#endif
    }
开发者ID:dkoerner,项目名称:embree,代码行数:32,代码来源:network.cpp

示例2: bind

    socket_t bind(unsigned short port)
    {
      initialize();

      /*! create a new socket */
      SOCKET sockfd = ::socket(AF_INET, SOCK_STREAM, 0);
      if (sockfd == INVALID_SOCKET) THROW_RUNTIME_ERROR("cannot create socket");

      /* When the server completes, the server socket enters a time-wait state during which the local
      address and port used by the socket are believed to be in use by the OS. The wait state may
      last several minutes. This socket option allows bind() to reuse the port immediately. */
#ifdef SO_REUSEADDR
      { int flag = true; ::setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (const char*)&flag, sizeof(int)); }
#endif
      
      /*! bind socket to port */
      struct sockaddr_in serv_addr;
      memset((char *) &serv_addr, 0, sizeof(serv_addr));
      serv_addr.sin_family = AF_INET;
      serv_addr.sin_port = (unsigned short) htons(port);
      serv_addr.sin_addr.s_addr = INADDR_ANY;

      if (::bind(sockfd, (struct sockaddr*) &serv_addr, sizeof(serv_addr)) < 0)
        THROW_RUNTIME_ERROR("binding to port "+toString(port)+" failed");
      
      /*! listen to port, up to 5 pending connections */
      if (::listen(sockfd,5) < 0)
        THROW_RUNTIME_ERROR("listening on socket failed");

      return (socket_t) new buffered_socket_t(sockfd);
    }
开发者ID:dkoerner,项目名称:embree,代码行数:31,代码来源:network.cpp

示例3: wait

    __forceinline void wait()
    {
      /* every thread entering the barrier decrements this count */
      size_t i0 = i;
      size_t cnt0 = enterCount--;

      /* all threads except the last one are wait in the barrier */
      if (cnt0 > 1) 
      {
        if (WaitForSingleObject(events[i0], INFINITE) != WAIT_OBJECT_0)
          THROW_RUNTIME_ERROR("WaitForSingleObjects failed");
      }
      
      /* the last thread starts all threads waiting at the barrier */
      else 
      {
        i = 1-i;
        enterCount.store(barrierSize);
        if (SetEvent(events[i0]) == 0)
          THROW_RUNTIME_ERROR("SetEvent failed");
      }

      /* every thread leaving the barrier decrements this count */
      size_t cnt1 = exitCount--;

      /* the last thread that left the barrier resets the event again */
      if (cnt1 == 1) 
      {
        exitCount.store(barrierSize);
        if (ResetEvent(events[i0]) == 0)
          THROW_RUNTIME_ERROR("ResetEvent failed");
      }
    }
开发者ID:tunabrain,项目名称:tungsten,代码行数:33,代码来源:barrier.cpp

示例4: switch

  void Scene::createHairAccel()
  {
    if (g_hair_accel == "default") 
    {
      if (isStatic()) {
        int mode =  2*(int)isCompact() + 1*(int)isRobust(); 
        switch (mode) {
        case /*0b00*/ 0: accels.add(BVH4::BVH4OBBBezier1v(this,isHighQuality())); break;
        case /*0b01*/ 1: accels.add(BVH4::BVH4OBBBezier1v(this,isHighQuality())); break;
        case /*0b10*/ 2: accels.add(BVH4::BVH4OBBBezier1i(this,isHighQuality())); break;
        case /*0b11*/ 3: accels.add(BVH4::BVH4OBBBezier1i(this,isHighQuality())); break;
        }
      } 
      else 
      {
        int mode =  2*(int)isCompact() + 1*(int)isRobust();
        switch (mode) {
	case /*0b00*/ 0: accels.add(BVH4::BVH4Bezier1v(this)); break;
        case /*0b01*/ 1: accels.add(BVH4::BVH4Bezier1v(this)); break;
        case /*0b10*/ 2: accels.add(BVH4::BVH4Bezier1i(this)); break;
        case /*0b11*/ 3: accels.add(BVH4::BVH4Bezier1i(this)); break;
        }
      }   
    }
    else if (g_hair_accel == "bvh4.bezier1v"    ) accels.add(BVH4::BVH4Bezier1v(this));
    else if (g_hair_accel == "bvh4.bezier1i"    ) accels.add(BVH4::BVH4Bezier1i(this));
    else if (g_hair_accel == "bvh4obb.bezier1v" ) accels.add(BVH4::BVH4OBBBezier1v(this,false));
    else if (g_hair_accel == "bvh4obb.bezier1i" ) accels.add(BVH4::BVH4OBBBezier1i(this,false));
    else THROW_RUNTIME_ERROR("unknown hair acceleration structure "+g_hair_accel);
  }
开发者ID:JianpingCAI,项目名称:libigl,代码行数:30,代码来源:scene.cpp

示例5: connect

    socket_t connect(const char* host, unsigned short port) 
    {
      initialize();

      /*! create a new socket */
      SOCKET sockfd = ::socket(AF_INET, SOCK_STREAM, 0);
      if (sockfd == INVALID_SOCKET) THROW_RUNTIME_ERROR("cannot create socket");
      
      /*! perform DNS lookup */
      struct hostent* server = ::gethostbyname(host);
      if (server == nullptr) THROW_RUNTIME_ERROR("server "+std::string(host)+" not found");
      
      /*! perform connection */
      struct sockaddr_in serv_addr;
      memset((char*)&serv_addr, 0, sizeof(serv_addr));
      serv_addr.sin_family = AF_INET;
      serv_addr.sin_port = (unsigned short) htons(port);
      memcpy((char*)&serv_addr.sin_addr.s_addr, (char*)server->h_addr, server->h_length);
      
      if (::connect(sockfd,(struct sockaddr*) &serv_addr,sizeof(serv_addr)) < 0)
        THROW_RUNTIME_ERROR("connection to "+std::string(host)+":"+toString(port)+" failed");

      /*! enable TCP_NODELAY */
#ifdef TCP_NODELAY
      { int flag = 1; ::setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (const char*)&flag, sizeof(int)); }
#endif

      /*! we do not want SIGPIPE to be thrown */
#ifdef SO_NOSIGPIPE
      { int flag = 1; setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, (const char*) &flag, sizeof(int)); }
#endif
      
      return (socket_t) new buffered_socket_t(sockfd);
    }
开发者ID:dkoerner,项目名称:embree,代码行数:34,代码来源:network.cpp

示例6: loadHairASCII

  int loadHairASCII(const FileName& fileName, OBJScene::HairSet* hairset, Vec3fa& offset)
  {  
    /* open hair file */
    FILE* f = fopen(fileName.c_str(),"r");
    if (!f) THROW_RUNTIME_ERROR("could not open " + fileName.str());

    char line[10000];
    fgets(line,10000,f);
    int numCurves = 0;
    
    while (fgets(line,10000,f) && !feof(f))
    {
      /* comment */
      if (line[0] == '#')
	continue;
      
      if (!strncmp(line,"Curve:",strlen("Curve:")))
      {
        char name[1000];
        unsigned int tracks, points;
        sscanf(line,"Curve: %s %d Tracks %d Points",name,&tracks,&points);

        /* skip Tracks line */
        fgets(line,10000,f);
        
        const int vertex_start_id = hairset->v.size();
        
        unsigned int id = 0;
        for (int i=0; i<points; i++)
        {
          fgets(line,10000,f);

          /* comment */
          if (line[0] == '#' || !strncmp(line," Tracks:",strlen(" Tracks:")))
            continue;

          Vec3fa v;
          if (i == 0) sscanf(line,"%d : Bezier %f %f %f %f",&id,&v.x,&v.y,&v.z,&v.w);
          else        sscanf(line,"%d : %f %f %f %f",&id,&v.x,&v.y,&v.z,&v.w);
          //printf("%d %d : %f %f %f %f \n",id,vertex_start_id+id,v.x,v.y,v.z,v.w);		
          v.x-=offset.x;
          v.y-=offset.y;
          v.z-=offset.z;
          hairset->v.push_back(v);
        }
        
        /* add indices to hair starts */
        for (int i=0; i<points-1; i+=3)
          hairset->hairs.push_back(OBJScene::Hair(vertex_start_id + i,numCurves));
	
        if (id != points-1) 
          THROW_RUNTIME_ERROR("hair parsing error");

        numCurves++;
      }
    }
    fclose(f);
    return numCurves;
  }
开发者ID:davenso,项目名称:embree,代码行数:59,代码来源:hair_loader.cpp

示例7: THROW_RUNTIME_ERROR

 Ref<SceneGraph::Node> CoronaLoader::loadObject(const Ref<XML>& xml) 
 {
   if (xml->name != "object") 
     THROW_RUNTIME_ERROR(xml->loc.str()+": invalid object node");
   if (xml->parm("class") != "file")
     THROW_RUNTIME_ERROR(xml->loc.str()+": invalid object class");
   const FileName fileName = load<FileName>(xml);
   return SceneGraph::load(path+fileName);
 }
开发者ID:appleseedhq,项目名称:appleseed-deps,代码行数:9,代码来源:corona_loader.cpp

示例8: createTriangleMeshTriangle4i

 void createTriangleMeshTriangle4i(TriangleMesh* mesh, AccelData*& accel, Builder*& builder)
 {
   if (mesh->numTimeSteps != 1) THROW_RUNTIME_ERROR("internal error");
   accel = new BVH4(Triangle4i::type,mesh->parent,LeafMode);
   switch (mesh->flags) {
   case RTC_GEOMETRY_STATIC:     builder = BVH4Triangle4iMeshBuilderSAH(accel,mesh,LeafMode); break;
   case RTC_GEOMETRY_DEFORMABLE: builder = BVH4Triangle4iMeshRefitSAH(accel,mesh,LeafMode); break;
   case RTC_GEOMETRY_DYNAMIC:    builder = BVH4Triangle4iMeshBuilderMortonGeneral(accel,mesh,LeafMode); break;
   default: THROW_RUNTIME_ERROR("internal error"); 
   }
 } 
开发者ID:baxelrod,项目名称:embree,代码行数:11,代码来源:bvh4.cpp

示例9: init

    void init(const boost::property_tree::ptree& pt) throw(std::runtime_error) {
        if (m_acceptor.is_open())
            m_acceptor.close();

        std::string url = pt.get<std::string>("address", "");
        std::string proto, addr, port, path;
        if (url.empty() || !parse_url(url, proto, addr, port, path))
            THROW_RUNTIME_ERROR("Invalid URL address: '" << url << "'");
        if (proto != "uds")
            THROW_RUNTIME_ERROR("Expected 'uds' protocol type!");
        if (path.empty())
            THROW_RUNTIME_ERROR("uds_server empty 'address' configuration");
        m_endpoint.path(path);
    }
开发者ID:erlanger,项目名称:eixx,代码行数:14,代码来源:server.hpp

示例10: createTls

  /*! creates thread local storage */
  tls_t createTls() {
    pthread_key_t* key = new pthread_key_t;
    if (pthread_key_create(key,NULL) != 0)
      THROW_RUNTIME_ERROR("pthread_key_create");

    return tls_t(key);
  }
开发者ID:utkarshayachit,项目名称:OSPRay,代码行数:8,代码来源:thread.cpp

示例11: switch

  void TaskSchedulerSys::add(ssize_t threadIndex, QUEUE queue, Task* task)
  {
    if (task->event) 
      task->event->inc();

    mutex.lock();

    /*! resize array if too small */
    if (end-begin == tasks.size())
    {
      size_t s0 = 1*tasks.size();
      size_t s1 = 2*tasks.size();
      tasks.resize(s1);
      for (size_t i=begin; i!=end; i++)
        tasks[i&(s1-1)] = tasks[i&(s0-1)];
    }

    /*! insert task to correct end of list */
    switch (queue) {
    case GLOBAL_FRONT: { size_t i = (--begin)&(tasks.size()-1); tasks[i] = task; break; }
    case GLOBAL_BACK : { size_t i = (end++  )&(tasks.size()-1); tasks[i] = task; break; }
    default          : THROW_RUNTIME_ERROR("invalid task queue");
    }
    
    condition.broadcast();
    mutex.unlock();
  }
开发者ID:D-POWER,项目名称:embree,代码行数:27,代码来源:taskscheduler_sys.cpp

示例12: THROW_RUNTIME_ERROR

void TextureAsset::load(XMLElement* fileElement, tinyxml2::XMLDocument& metaDocument)
{
	Asset::load(fileElement, metaDocument);

	texture = new sf::Texture();
	THROW_RUNTIME_ERROR(texture->loadFromFile(rawAssetPath.c_str()) == false, "Unable to load: " + rawAssetPath);
}
开发者ID:elsioneto1,项目名称:SpaceShootersz,代码行数:7,代码来源:TextureAsset.cpp

示例13: write

    void write(socket_t hsock_i, const void* data_i, size_t bytes)
    {
#if BUFFERING
      const char* data = (const char*) data_i;
      buffered_socket_t* hsock = (buffered_socket_t*) hsock_i;
      while (bytes) {
        if (hsock->oend == hsock->osize) flush(hsock_i);
        size_t bsize = hsock->osize-hsock->oend;
        if (bytes < bsize) bsize = bytes;
        memcpy(hsock->obuf+hsock->oend,data,bsize);
        data += bsize;
        hsock->oend += bsize;
        bytes -= bsize;
      }
#else
      const char* data = (const char*) data_i;
      buffered_socket_t* hsock = (buffered_socket_t*) hsock_i;
      while (bytes) {
        ssize_t n = ::write(hsock->fd,data,bytes);
        if (n  < 0) THROW_RUNTIME_ERROR("error writing to socket");
        data+=n;
        bytes-=n;
      }
#endif
    }
开发者ID:dkoerner,项目名称:embree,代码行数:25,代码来源:network.cpp

示例14: while

int ExceptionDialog::wait()
{
	if ( !_valid )
	{
		throw std::invalid_argument("ExceptionDialog is not a valid dialog form!");
		return -1;
	}

	MSG msg;
	BOOL result;

	while ( (result = GetMessage(&msg, (HWND)_native_handle, 0, 0)) != 0 && IsWindow((HWND)_native_handle) )
	{
		if ( result == -1 )
		{
			// Error occured
			THROW_RUNTIME_ERROR( std::string("An error occured in GetMessage with code ") + std::to_string(GetLastError()) );
			return -1;
		}
		else
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
	}

	return msg.wParam;
}
开发者ID:Rexhunter99,项目名称:atmosphere-x,代码行数:28,代码来源:ExceptionDialog.cpp

示例15: THROW_RUNTIME_ERROR

 MutexSys::~MutexSys( void ) 
 { 
   if (pthread_mutex_destroy((pthread_mutex_t*)mutex) != 0)
     THROW_RUNTIME_ERROR("pthread_mutex_destroy failed");
   
   delete (pthread_mutex_t*)mutex; 
 }
开发者ID:davenso,项目名称:embree,代码行数:7,代码来源:mutex.cpp


注:本文中的THROW_RUNTIME_ERROR函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。