Package io.apigee.trireme.core

Examples of io.apigee.trireme.core.ScriptTask


            if (log.isDebugEnabled()) {
                log.debug("Received HTTP onData for {} with {}", request, data);
            }
            final ByteBuffer requestData =
                    (data.hasData() ? data.getData() : null);
            runner.enqueueTask(new ScriptTask()
            {
                @Override
                public void execute(Context cx, Scriptable scope)
                {
                    callOnData(cx, scope, request, requestData);
                }
            });
            if (data.isLastChunk()) {
                runner.enqueueTask(new ScriptTask()
                {
                    @Override
                    public void execute(Context cx, Scriptable scope)
                    {
                        callOnComplete(cx, request);
View Full Code Here


        @Override
        public void onClose(final HttpRequestAdapter request, final HttpResponseAdapter response)
        {
            if (request != null) {
                runner.enqueueTask(new ScriptTask() {
                    @Override
                    public void execute(Context cx, Scriptable scope) {
                        Scriptable reqObject = request.getScriptObject();
                        Object respObject;
                        if (response != null) {
View Full Code Here

                {
                    if (log.isDebugEnabled()) {
                        log.debug("Write complete: success = {} closed = {} cause = {}", success, closed, cause);
                    }
                    Scriptable domain = server.getRunner().getDomain();
                    server.getRunner().enqueueTask(new ScriptTask()
                    {
                        @Override
                        public void execute(Context cx, Scriptable scope)
                        {
                            Scriptable err = null;
View Full Code Here

        // We are in the thread pool, and we need to run the callback in the script thread. So we will
        // call "enqueueTask" to get back there.
        // All the JS and Java code written for Node.js assumes that it is running in this thread,
        // and it is not synchronized, so it's very important that we call this to get back to
        // the right thread -- otherwise we will corrupt all sorts of state.
        runtime.enqueueTask(new ScriptTask() {
            @Override
            public void execute(Context cx, Scriptable scope)
            {
                // The callback just expects an Error as the first parameter, or nothing if
                // we succeeded, so set that up here
View Full Code Here

        // We are in the thread pool, and we need to run the callback in the script thread. So we will
        // call "enqueueTask" to get back there.
        // All the JS and Java code written for Node.js assumes that it is running in this thread,
        // and it is not synchronized, so it's very important that we call this to get back to
        // the right thread -- otherwise we will corrupt all sorts of state.
        runtime.enqueueTask(new ScriptTask() {
            @Override
            public void execute(Context cx, Scriptable scope)
            {
                // Rather than throw an error, we need to pass an Error object as the first parameter
                // to the callback. This will construct it in a convenient way.
View Full Code Here

    }

    private void deliverResult(final byte[] buf, final int length, final Function cb, Object domain)
    {
        // Again, get back to the script thread.
        runtime.enqueueTask(new ScriptTask() {
            @Override
            public void execute(Context cx, Scriptable scope)
            {
                if (length >= 0) {
                    // Create a Node.js Buffer object from the data that we just read.
View Full Code Here

        final Object reallyDeliver = toDeliver;
        final String fevent = event;
        if (child == null) {
            // We are called on child's script runtime, so enqueue a task here
            enqueueTask(new ScriptTask() {
                @Override
                public void execute(Context cx, Scriptable scope)
                {
                    if ("disconnect".equals(fevent)) {
                        // Special handling for a disconnect from the parent
                        if (process.isConnected()) {
                            process.setConnected(false);
                            process.getEmit().call(cx, scope, process, new Object[] { fevent });
                        }
                    } else {
                        process.getEmit().call(cx, scope, process,
                                               new Object[] { fevent, reallyDeliver });
                    }
                }
            });

        } else {
            // We are the child's script runtime. Enqueue task that sends to the parent
            // "child" here actually refers to the "child_process" object inside the parent!
            assert(child.getRuntime() != this);
            child.getRuntime().enqueueTask(new ScriptTask()
            {
                @Override
                public void execute(Context cx, Scriptable scope)
                {
                    // Now we should be running inside the script thread of the other script
View Full Code Here

TOP

Related Classes of io.apigee.trireme.core.ScriptTask

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.