/**
 *  Select
 */
void SelectorImplNSPR::select(vpr::Uint16& numWithEvents,
                              const vpr::Interval& timeout)
{
   PRInt32 result;

   // Call poll - If timeout == 0, then make sure we pass 0
   result = PR_Poll(&(mPollDescs[0]), mPollDescs.size(),
                    NSPR_getInterval(timeout));

   if ( -1 == result )
   {
      //NSPR_PrintError("SelectorImplNSPR::select: Error selecting. ");
      std::stringstream msg_stream;
      msg_stream << "[vpr::SelectorImplNSPR::select()] Error selecting.";
      vpr::Error::outputCurrentError(std::cerr, msg_stream.str());

      numWithEvents = 0;

      msg_stream << ": " << vpr::Error::getCurrentErrorMsg();
      throw IOException(msg_stream.str(), VPR_LOCATION);
   }
   else if ( 0 == result )    // Timeout
   {
      numWithEvents = 0;
      throw TimeoutException("Timeout occured while selecting.", VPR_LOCATION);
   }
   //else                    // Got some

   numWithEvents = result;
}
Exemple #2
0
bool CondVarNSPR::wait(const vpr::Interval& timeToWait)
{
    const PRStatus status = PR_WaitCondVar(mCondVar,
                                           NSPR_getInterval(timeToWait));

    // XXX: How do we deal with a timeout?
    if ( PR_SUCCESS != status )
    {
        std::ostringstream msg_stream;
        NSPR_PrintError("Unexpected error: ", msg_stream);
        throw vpr::Exception(msg_stream.str(), VPR_LOCATION);
    }

    return true;
}