예제 #1
0
    virtual void run() final
    {
        const bool boolIn = true;
        uint8_t* payload = (uint8_t*)42;

        uint32_t request = requestQ_.pop();
        TEST( handler_.getRequestData( request ) == ++payload );
        handler_.serveRequest( request, boolIn );

        const uint32_t uint32In = 0xC0FFEE;
        request = requestQ_.pop();
        TEST( handler_.getRequestData( request ) == ++payload );
        handler_.serveRequest( request, uint32In );

        request = requestQ_.pop();
        TEST( handler_.getRequestData( request ) == ++payload );
        handler_.serveRequest( request );

        request = requestQ_.pop();
        TESTINFO( handler_.getRequestData( request ) == ++payload,
                  (size_t)handler_.getRequestData( request ) << " for " <<
                  request );
        handler_.serveRequest( request );

        request = requestQ_.pop();
        TEST( handler_.getRequestData( request ) == ++payload );
        handler_.serveRequest( request, uuid );

        request = requestQ_.pop();
        TEST( handler_.getRequestData( request ) == ++payload );
        handler_.serveRequest( request );
    }
예제 #2
0
    void run() override
    {
        if( _master )
            setName( "MasterWorker" );
        else
            setName( "SlaveWorker" );

        _registered.waitEQ( true );
        if( _master )
        {
            _barrier = new co::Barrier( _node, _barrierID );
            _mapped = true;
        }
        else
            _mapped.waitEQ( true );

        for( size_t i = 0; i < _numIterations; ++i )
        {
            const co::uint128_t& version = _versions.pop();

            {
                static lunchbox::SpinLock lock;
                lunchbox::ScopedFastWrite mutex( lock );
                _barrier->sync( version );
            }

            TEST( _barrier->isGood());
            _barrier->enter();
        }

        if( _master )
        {
            _done = true;
            _versions.clear();
            _node->releaseObject( _barrier );
            delete _barrier;
        }
    }