Package org.agilewiki.jactor2.core.impl

Examples of org.agilewiki.jactor2.core.impl.Plant


    /**
     * Create a plant with the default configuration.
     */
    public Plant() throws Exception {
        new PlantMtImpl();
    }
View Full Code Here


     *
     * @param _reactorThreadPoolSize The number of threads to be created for the
     *                               reactor thread pool.
     */
    public Plant(final int _reactorThreadPoolSize) throws Exception {
        new PlantMtImpl(_reactorThreadPoolSize);
    }
View Full Code Here

     * Create a plant with the given configuration.
     *
     * @param _plantConfiguration The configuration to be used by the plant.
     */
    public Plant(final PlantConfiguration _plantConfiguration) throws Exception {
        new PlantMtImpl(_plantConfiguration);
    }
View Full Code Here

            }
        }

        shuttingDown = true;

        final PlantMtImpl plantImpl = PlantMtImpl.getSingleton();
        if ((plantImpl != null) && isRunning()
                && ((currentRequest == null) || !currentRequest.isComplete())) {
            timeoutSemaphore = plantImpl.schedulableSemaphore(recovery
                    .getThreadInterruptMillis(this));
            final Thread thread = getThreadReference().get();
            if (thread != null) {
                thread.interrupt();
                boolean timeout = false;
View Full Code Here

                final ReactorPoolThread currentThread = (ReactorPoolThread) Thread
                        .currentThread();
                while (true) {
                    try {
                        taskRequest.acquire();
                        PoolThreadReactorMtImpl reactor = reactors.poll();
                        if (reactor != null) {
                            AtomicReference<Thread> threadReference = reactor
                                    .getThreadReference();
                            if ((threadReference.get() == null)
                                    && threadReference.compareAndSet(null,
                                            currentThread)) {
                                currentThread.setCurrentReactor(reactor);
                                while (true) {
                                    try {
                                        reactor.run();
                                    } catch (final MigrationException me) {
                                        final boolean hasWork = reactor
                                                .hasWork();
                                        threadReference.set(null);
                                        if (reactor.isIdler() || hasWork
                                                || reactor.hasConcurrent()) {
                                            execute(reactor);
                                        }
                                        reactor = me.reactor;
                                        threadReference = reactor
                                                .getThreadReference();
                                        currentThread
                                                .setCurrentReactor(reactor);
                                        continue;
                                    } catch (final Throwable e) {
                                        logger.error(
                                                "Exception thrown by a targetReactor's run method",
                                                e);
                                    }
                                    final boolean hasWork = reactor.hasWork();
                                    threadReference.set(null);
                                    if (hasWork || reactor.hasConcurrent()) {
                                        execute(reactor);
                                    }
                                    break;
                                }
                                currentThread.setCurrentReactor(null);
View Full Code Here

                    }
                };
                long j = 0;
                while (j < count) {
                    j++;
                    final DelayAOp delay = new DelayAOp(100);
                    _asyncRequestImpl.send(delay, delayResponseProcessor);
                }
            }
        };
    }
View Full Code Here

        final AsyncTransaction<String, TransmutableString> addGood = new AsyncTransaction<String, TransmutableString>() {
            @Override
            protected void update(final TransmutableString transmutable,
                                  final AsyncResponseProcessor<Void> asyncResponseProcessor)
                    throws Exception {
                applyAReq.send(new DelayAOp(1000),
                        new AsyncResponseProcessor<Void>() {
                            @Override
                            public void processAsyncResponse(
                                    final Void _response) throws Exception {
                                transmutable.stringBuilder.insert(0, "good ");
View Full Code Here

                    throws Exception {
                IHung iHung = new IHung();
                final AOp<Void> noRspAOp = iHung.noRspAOp();
                final AsyncRequestImpl<Void> noRspImpl = _asyncRequestImpl.send(noRspAOp, _asyncResponseProcessor);
                _asyncRequestImpl.send(iHung.getReactor().nullSOp(), _asyncResponseProcessor);
                _asyncRequestImpl.send(new DelayAOp(100), new AsyncResponseProcessor<Void>() {
                    @Override
                    public void processAsyncResponse(final Void _response) {
                        _asyncRequestImpl.cancel(noRspImpl);
                    }
                });
View Full Code Here

    /**
     * Closes all reactors and associated closeables, the plant scheduler and the
     * reactor thread pool.
     */
    public static void close() throws Exception {
        final PlantImpl plantImpl = PlantImpl.getSingleton();
        if (plantImpl != null) {
            plantImpl.close();
        }
    }
View Full Code Here

class A3 extends AOp<Long> {
    final long delay;

    A3(final String _name, final long _delay) throws Exception {
        super(_name, new BlockingReactor());
        delay = _delay;
    }
View Full Code Here

TOP

Related Classes of org.agilewiki.jactor2.core.impl.Plant

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.