Package org.apache.felix.eventadmin.impl.handler

Examples of org.apache.felix.eventadmin.impl.handler.EventHandlerProxy


        final Iterator<EventHandlerProxy> i = tasks.iterator();
        final BlacklistLatch handlerLatch = new BlacklistLatch(tasks.size(), this.timeout/2);

        while ( i.hasNext() )
        {
            final EventHandlerProxy task = i.next();
            HandlerTask handlerTask = new HandlerTask(task, event, this.timeout, handlerLatch);
//            if ( !filterAsyncUnordered || task.isAsyncOrderedDelivery() )
//            {
                if( !handlerTask.useTimeout() )
                {
View Full Code Here


        final SyncThread syncThread = sleepingThread instanceof SyncThread ? (SyncThread)sleepingThread : null;

        final Iterator<EventHandlerProxy> i = tasks.iterator();
        while ( i.hasNext() )
        {
            final EventHandlerProxy task = i.next();
//            if ( !filterAsyncUnordered || task.isAsyncOrderedDelivery() )
//            {
                if ( !useTimeout(task) )
                {
                    // no timeout, we can directly execute
                    task.sendEvent(event);
                }
                else if ( syncThread != null )
                {
                    // if this is a cascaded event, we directly use this thread
                    // otherwise we could end up in a starvation
                    final long startTime = System.currentTimeMillis();
                    task.sendEvent(event);
                    if ( System.currentTimeMillis() - startTime > this.timeout )
                    {
                        task.blackListHandler();
                    }
                }
                else
                {
                    final Rendezvous startBarrier = new Rendezvous();
                    final Rendezvous timerBarrier = new Rendezvous();
                    this.pool.executeTask(new Runnable()
                    {
                        @Override
                        public void run()
                        {
                            try
                            {
                                // notify the outer thread to start the timer
                                startBarrier.waitForRendezvous();
                                // execute the task
                                task.sendEvent(event);
                                // stop the timer
                                timerBarrier.waitForRendezvous();
                            }
                            catch (final IllegalStateException ise)
                            {
                                // this can happen on shutdown, so we ignore it
                            }
                        }
                    });
                    // we wait for the inner thread to start
                    startBarrier.waitForRendezvous();

                    // timeout handling
                    // we sleep for the sleep time
                    // if someone wakes us up it's the finished inner task
                    try
                    {
                        timerBarrier.waitAttemptForRendezvous(this.timeout);
                    }
                    catch (final TimeoutException ie)
                    {
                        // if we timed out, we have to blacklist the handler
                        task.blackListHandler();
                    }

                }
//            }
        }
View Full Code Here

TOP

Related Classes of org.apache.felix.eventadmin.impl.handler.EventHandlerProxy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.