Пример #1
0
void Config::notifyNodeFrameFinished( const uint32_t frameNumber )
{
    if( _finishedFrame >= frameNumber ) // node finish already done
        return;

    const Nodes& nodes = getNodes();
    for( Nodes::const_iterator i = nodes.begin(); i != nodes.end(); ++i )
    {
        const Node* node = *i;
        if( node->isRunning() && node->getFinishedFrame() < frameNumber )
        {
            LBASSERT( _needsFinish || node->isActive( ));
            return;
        }
    }

    _finishedFrame = frameNumber;

    // All nodes have finished the frame. Notify the application's config that
    // the frame is finished

    // do not use send/_bufferedTasks, not thread-safe!
    send( findApplicationNetNode(),
          fabric::CMD_CONFIG_FRAME_FINISH ) << frameNumber;
    LBLOG( LOG_TASKS ) << "TASK config frame finished  " << " frame "
                       << frameNumber << std::endl;
}
Пример #2
0
//---------------------------------------------------------------------------
// exit
//---------------------------------------------------------------------------
bool Config::exit()
{
    if( _state != STATE_RUNNING )
        LBWARN << "Exiting non-initialized config" << std::endl;

    LBASSERT( _state == STATE_RUNNING || _state == STATE_INITIALIZING );
    _state = STATE_EXITING;

    const Canvases& canvases = getCanvases();
    for( Canvases::const_iterator i = canvases.begin();
         i != canvases.end(); ++i )
    {
        Canvas* canvas = *i;
        canvas->exit();
    }

    for( Compounds::const_iterator i = _compounds.begin();
         i != _compounds.end(); ++i )
    {
        Compound* compound = *i;
        compound->exit();
    }

    const bool success = _updateRunning( true );

    // send exit event to app, needed if this is called from init()
    EventOCommand cmd( send( findApplicationNetNode(),
                             fabric::CMD_CONFIG_EVENT ));
    Event event;
    event.serial = getSerial();
    event.time = getServer()->getTime();
    event.originator = getID();

    cmd << EVENT_EXIT << event;

    _needsFinish = false;
    _state = STATE_STOPPED;
    return success;
}
Пример #3
0
//---------------------------------------------------------------------------
// frame
//---------------------------------------------------------------------------
void Config::_startFrame( const uint128_t& frameID )
{
    LBASSERT( _state == STATE_RUNNING );
    _verifyFrameFinished( _currentFrame );
    _syncClock();

    ++_currentFrame;
    ++_incarnation;
    LBLOG( LOG_TASKS ) << "----- Start Frame ----- " << _currentFrame
                       << std::endl;

    for( Compounds::const_iterator i = _compounds.begin();
         i != _compounds.end(); ++i )
    {
        Compound* compound = *i;
        compound->update( _currentFrame );
    }

    ConfigUpdateDataVisitor configDataVisitor;
    accept( configDataVisitor );

    const Nodes& nodes = getNodes();
    co::NodePtr appNode = findApplicationNetNode();
    for( Nodes::const_iterator i = nodes.begin(); i != nodes.end(); ++i )
    {
        Node* node = *i;
        node->update( frameID, _currentFrame );
        if( node->isRunning() && node->isApplicationNode( ))
            appNode = 0; // release sent (see below)
    }

    if( appNode ) // release appNode local sync
        send( appNode,
              fabric::CMD_CONFIG_RELEASE_FRAME_LOCAL ) << _currentFrame;

    // Fix 2976899: Config::finishFrame deadlocks when no nodes are active
    notifyNodeFrameFinished( _currentFrame );
}
Пример #4
0
//---------------------------------------------------------------------------
// exit
//---------------------------------------------------------------------------
bool Config::exit()
{
    if( _state != STATE_RUNNING )
        LBWARN << "Exiting non-initialized config" << std::endl;

    LBASSERT( _state == STATE_RUNNING || _state == STATE_INITIALIZING );
    _state = STATE_EXITING;

    const Canvases& canvases = getCanvases();
    for( Canvases::const_iterator i = canvases.begin();
         i != canvases.end(); ++i )
    {
        Canvas* canvas = *i;
        canvas->exit();
    }

    for( Compounds::const_iterator i = _compounds.begin();
         i != _compounds.end(); ++i )
    {
        Compound* compound = *i;
        compound->exit();
    }

    const bool success = _updateRunning( true );

    // TODO: is this needed? sender of CMD_CONFIG_EXIT is the appNode itself
    // which sets the running state to false anyway. Besides, this event is
    // not handled by the appNode because it is already in exiting procedure
    // and does not call handleEvents anymore
    // eile: May be needed for reliability?
    send( findApplicationNetNode(), fabric::CMD_CONFIG_EVENT ) << Event::EXIT;

    _needsFinish = false;
    _state = STATE_STOPPED;
    return success;
}
Пример #5
0
EventOCommand Config::sendError( const uint32_t type, const Error& error )
{
    return Super::sendError( findApplicationNetNode(), type, error );
}