예제 #1
0
void ApplicationCacheGroup::callListenersOnAssociatedDocuments(ListenerFunction listenerFunction)
{
    Vector<RefPtr<DocumentLoader> > loaders;
    copyToVector(m_associatedDocumentLoaders, loaders);

    callListeners(listenerFunction, loaders);
}
예제 #2
0
void ChangeBroadcaster::sendSynchronousChangeMessage()
{
    // This can only be called by the event thread.
    jassert (MessageManager::getInstance()->isThisTheMessageThread());

    callback.cancelPendingUpdate();
    callListeners();
}
예제 #3
0
void TextPropertyComponent::textWasEdited()
{
    auto newText = textEditor->getText();

    if (getText() != newText)
        setText (newText);

    callListeners();
}
예제 #4
0
    void sendParentChangeMessage()
    {
        ValueTree tree (this);

        for (int j = children.size(); --j >= 0;)
            if (SharedObject* const child = children.getObjectPointer (j))
                child->sendParentChangeMessage();

        callListeners (&ValueTree::Listener::valueTreeParentChanged, tree);
    }
예제 #5
0
    void sendParentChangeMessage()
    {
        ValueTree tree (this);

        for (int j = children.size(); --j >= 0;)
            if (auto* child = children.getObjectPointer (j))
                child->sendParentChangeMessage();

        callListeners ([&] (ListenerList<Listener>& list) { list.call (&ValueTree::Listener::valueTreeParentChanged, tree); });
    }
예제 #6
0
    void sendParentChangeMessage()
    {
        ValueTree tree (*this);

        for (auto j = children.size(); --j >= 0;)
            if (auto* child = children.getObjectPointer (j))
                child->sendParentChangeMessage();

        callListeners (nullptr, [&] (Listener& l) { l.valueTreeParentChanged (tree); });
    }
예제 #7
0
void Value::referTo (const Value& valueToReferTo)
{
    if (valueToReferTo.value != value)
    {
        if (listeners.size() > 0)
        {
            value->valuesWithListeners.removeValue (this);
            valueToReferTo.value->valuesWithListeners.add (this);
        }

        value = valueToReferTo.value;
        callListeners();
    }
}
예제 #8
0
void ApplicationCacheGroup::checkIfLoadIsComplete()
{
    ASSERT(m_cacheBeingUpdated);
    
    if (m_manifestHandle)
        return;
    
    if (!m_pendingEntries.isEmpty())
        return;
    
    // We're done    
    bool isUpgradeAttempt = m_newestCache;
    
    m_cacheBeingUpdated->setManifestResource(m_manifestResource.release());
    
    Vector<RefPtr<DocumentLoader> > documentLoaders;

    if (isUpgradeAttempt) {
        ASSERT(m_cacheCandidates.isEmpty());
        
        copyToVector(m_associatedDocumentLoaders, documentLoaders);
    } else {
        while (!m_cacheCandidates.isEmpty()) {
            HashSet<DocumentLoader*>::iterator it = m_cacheCandidates.begin();
            
            DocumentLoader* loader = *it;
            ASSERT(!loader->applicationCache());
            ASSERT(loader->candidateApplicationCacheGroup() == this);
            
            associateDocumentLoaderWithCache(loader, m_cacheBeingUpdated.get());
    
            documentLoaders.append(loader);

            m_cacheCandidates.remove(it);
        }
    }
    
    setNewestCache(m_cacheBeingUpdated.release());
        
    // Store the cache 
    cacheStorage().storeNewestCache(this);
    
    callListeners(isUpgradeAttempt ? &DOMApplicationCache::callUpdateReadyListener : &DOMApplicationCache::callCachedListener, 
                  documentLoaders);

    m_status = Idle;
    m_frame = 0;
}
예제 #9
0
    void handleFrame (double /*time*/, BYTE* buffer, long /*bufferSize*/)
    {
        if (recordNextFrameTime)
        {
            const double defaultCameraLatency = 0.1;

            firstRecordedTime = Time::getCurrentTime() - RelativeTime (defaultCameraLatency);
            recordNextFrameTime = false;

            ComSmartPtr<IPin> pin;
            if (getPin (filter, PINDIR_OUTPUT, pin))
            {
                ComSmartPtr<IAMPushSource> pushSource;
                HRESULT hr = pin.QueryInterface (pushSource);

                if (pushSource != nullptr)
                {
                    REFERENCE_TIME latency = 0;
                    hr = pushSource->GetLatency (&latency);

                    firstRecordedTime = firstRecordedTime - RelativeTime ((double) latency);
                }
            }
        }

        {
            const int lineStride = width * 3;
            const ScopedLock sl (imageSwapLock);

            {
                loadingImage.duplicateIfShared();
                const Image::BitmapData destData (loadingImage, 0, 0, width, height, Image::BitmapData::writeOnly);

                for (int i = 0; i < height; ++i)
                    memcpy (destData.getLinePointer ((height - 1) - i),
                            buffer + lineStride * i,
                            lineStride);
            }

            imageNeedsFlipping = true;
        }

        if (listeners.size() > 0)
            callListeners (loadingImage);

        sendChangeMessage();
    }
예제 #10
0
void Selector::threadMain()
{
	TRACE_BEGIN( LOG_LVL_INFO );
	bool gotEvent = false;
	struct pollfd	fds[ kMaxPollFds ];
	int				numFds = 0;
	
	fillPollFds( fds, numFds );
	
	// Event will be sent by EventThread on exit
	while( mRunning )
	{
		LOG( "%p on %d files", this, numFds );
		for ( int i = 1; i < numFds; i++ )
		{
			LOG( "%p fd %d", this, fds[ i ].fd );
		}
		
		// set errno to zero
		// this is being set to better monitor the behavior of poll on
		// the 7401 until poll gets fixed
		errno = 0;
		int res = 0;
		
		// test here to ensure that errno cannot be modified before it is tested.
		if ( ( res = poll( fds, numFds, -1 ) ) < 0 )
		{
			// for whatever reason, there are times when poll returns -1,
			// but doesn't set errno
			if (errno == 0)
				LOG_NOTICE( "Poll returned %d, but didn't set errno", res);
			else if (errno == EINTR)
				LOG_NOISE( "Poll was interrupted" );
			else
				LOG_ERR_PERROR( "Poll returned %d", res );
		}
		
		LOG( "%p woke up %d", this, res );
		
		if ( res > 0 )
		{
			LOG( "got %d from poll", res );
			
			for ( int i = 0; i < numFds; i++ )
			{
				if ( fds[ i ].fd == mPipe[ PIPE_READER ] )
				{
					LOG( "got %x on pipe %d", fds[ 0 ].revents, fds[ i ].fd );
					if ( fds[ i ].revents & POLLIN )
					{
						char buf[10];
						read( mPipe[ PIPE_READER ], &buf, 4 );
						
						// We need to handle events after we handle file
						// descriptor polls because one of the events
						// that we handle modifies the current list of
						// file descriptors for poll and we need to handle
						// any that occured before updating them.
						gotEvent = true;
					}			
					else if ( fds[ i ].revents & ( POLLHUP | POLLNVAL ) )
					{
						LOG_ERR_FATAL( "POLLHUP recieved on pipe" );
					}
				}
				else
				{
					LOG_NOISE( "got %x on fd %d", fds[ i ].revents, fds[ i ].fd );
					if ( fds[ i ].revents != 0 )
					{
						// if callListeners removes a listener we need to update 
						//  Fds.  However only set if callListeners returns true
						//  This should not be cleared since one of the listeners
						//  could have called removeListener and that call might 
						//  have set mUpdateFds
						if ( callListeners( fds[ i ].fd, fds[ i ].revents ) )
							mUpdateFds = true;
					}
				}
			}
		}

		// Now that file descriptors have been handled we can deal with
		// events if needed, including updating the poll file descriptor
		// list if it's been changed.
		if ( gotEvent )
		{
			Event *ev = mQueue.PollEvent();

			if ( ev == NULL )
			{
				LOG_WARN( "got NULL event" );
			}
			else if ( ev->getEventId() == Event::kSelectorUpdateEventId )
			{
				LOG( "got kSelectorUpdateEventId" );
				mUpdateFds = true;
				ev->Release();
			}
			else
			{
				LOG( "got event %d", ev->getEventId() );
				bool done = EventDispatcher::handleEvent( ev );
				if ( done )
					mRunning = false;
			}
			
			gotEvent = false;
		}
		
		if ( mUpdateFds )
		{
			fillPollFds( fds, numFds );
			mUpdateFds = false;
		}
		
		mCondition.Broadcast();
	}
	
	LOG_NOTICE( "Thread exiting" );
}