예제 #1
0
inline status wait_children(Children &cs) 
{ 
    BOOST_ASSERT(cs.size() >= 2); 

    typename Children::iterator it = cs.begin(); 
    while (it != cs.end()) 
    { 
        const status s = it->wait(); 
        ++it; 
        if (it == cs.end()) 
            return s; 
        else if (!s.exited() || s.exit_status() != EXIT_SUCCESS) 
        { 
            while (it != cs.end()) 
            { 
                it->wait(); 
                ++it; 
            } 
            return s; 
        } 
    } 

    BOOST_ASSERT(false); 
    return cs.begin()->wait(); 
} 
예제 #2
0
void GeoRSSLayer::_read ( const std::string &filename, Usul::Interfaces::IUnknown *caller, Usul::Interfaces::IUnknown *progress )
{
  // Make sure the file exists before reading.
  if ( false == boost::filesystem::exists ( filename ) )
    return;

  // Set the name.
  if ( true == this->name().empty() )
    this->name ( this->url() );

  // Scope the reading flag.
  Usul::Scope::Caller::RefPtr scope ( Usul::Scope::makeCaller ( boost::bind ( &GeoRSSLayer::reading, this, true ), 
                                                                boost::bind ( &GeoRSSLayer::reading, this, false ) ) );

  // TODO: I think a SAX parser is more appropraite here, because we can stop the parsing if there isn't new data.
  XmlTree::Document::RefPtr doc ( new XmlTree::Document );
  doc->load ( filename );

  // Get the date the stream was modified.
  Children lastPubDateNode ( doc->find ( "lastBuildDate", true ) );
  const std::string date ( false == lastPubDateNode.empty() ? lastPubDateNode.front()->value() : "" );
  boost::posix_time::ptime utcTime ( Minerva::Core::Data::Date::createFromRSS ( date ) );

  boost::posix_time::ptime lastDataUpdate ( Usul::Threads::Safe::get ( this->mutex(), _lastDataUpdate ) );

  std::cout << "Last data update: " << lastDataUpdate << std::endl;
  std::cout << "Last feed update: " << utcTime << std::endl;

  // Check the date against the time time we updated.
  if ( false == this->dirtyData() && false == lastDataUpdate.is_not_a_date_time() && false == utcTime.is_not_a_date_time() )
  {
    // Return now if the feed has not been updated.
    if ( lastDataUpdate >= utcTime )
    {
      // Our data doesn't need to be updated.
      this->dirtyData ( false );
      return;
    }
  }

  // Clear what we have.
  this->clear();

  unsigned int i ( 0 );

  // Get all the items.
  Children children ( doc->find ( "item", true ) );
  BOOST_FOREACH ( XmlTree::Node::ValidRefPtr node, children )
  {
    std::cout << "Adding item " << ++i << " of " << children.size() << std::endl;
    this->_parseItem( *node );
    
    if ( this->size() >= this->maximumItems() )
      break;
  }
예제 #3
0
 size_t outdegree() const {
     return children.size();
 }