Search in sources :

Example 1 with Kernel

use of com.jme3.network.kernel.Kernel in project jmonkeyengine by jMonkeyEngine.

the class NioEndpoint method close.

public void close(boolean flushData) {
    if (flushData) {
        closing = true;
        // Enqueue a close marker message to let the server
        // know we should close
        send(CLOSE_MARKER, false, true);
        return;
    }
    try {
        // Note: even though we may be disconnected from the socket.isConnected()
        // standpoint, it's still safest to tell the kernel so that it can be sure
        // to stop managing us gracefully.
        kernel.closeEndpoint(this);
    } catch (IOException e) {
        throw new KernelException("Error closing endpoint for socket:" + socket, e);
    }
}
Also used : IOException(java.io.IOException) KernelException(com.jme3.network.kernel.KernelException)

Example 2 with Kernel

use of com.jme3.network.kernel.Kernel in project jmonkeyengine by jMonkeyEngine.

the class UdpEndpoint method send.

public void send(ByteBuffer data) {
    if (!isConnected()) {
        throw new KernelException("Endpoint is not connected:" + this);
    }
    try {
        DatagramPacket p = new DatagramPacket(data.array(), data.position(), data.remaining(), address);
        // Just queue it up for the kernel threads to write
        // out
        kernel.enqueueWrite(this, p);
    //socket.send(p);
    } catch (Exception e) {
        if (e instanceof SocketException) {
            throw new KernelException("Error sending datagram to:" + address, e);
        } else if (e instanceof RuntimeException) {
            throw (RuntimeException) e;
        } else {
            throw new RuntimeException(e);
        }
    }
}
Also used : SocketException(java.net.SocketException) DatagramPacket(java.net.DatagramPacket) KernelException(com.jme3.network.kernel.KernelException) SocketException(java.net.SocketException) KernelException(com.jme3.network.kernel.KernelException) IOException(java.io.IOException)

Example 3 with Kernel

use of com.jme3.network.kernel.Kernel in project jmonkeyengine by jMonkeyEngine.

the class TestWriteToTexture method initOpenCL1.

private void initOpenCL1() {
    clContext = context.getOpenCLContext();
    clQueue = clContext.createQueue().register();
    programCache = new ProgramCache(clContext);
    //create kernel
    String cacheID = getClass().getName() + ".Julia";
    Program program = programCache.loadFromCache(cacheID);
    if (program == null) {
        LOG.info("Program not loaded from cache, create from sources instead");
        program = clContext.createProgramFromSourceFiles(assetManager, "jme3test/opencl/JuliaSet.cl");
        program.build();
        programCache.saveToCache(cacheID, program);
    }
    program.register();
    kernel = program.createKernel("JuliaSet").register();
    C = new Vector2f(0.12f, -0.2f);
}
Also used : Vector2f(com.jme3.math.Vector2f)

Example 4 with Kernel

use of com.jme3.network.kernel.Kernel in project jmonkeyengine by jMonkeyEngine.

the class HelloOpenCL method simpleInitApp.

@Override
public void simpleInitApp() {
    BitmapFont fnt = assetManager.loadFont("Interface/Fonts/Default.fnt");
    Context clContext = context.getOpenCLContext();
    if (clContext == null) {
        BitmapText txt = new BitmapText(fnt);
        txt.setText("No OpenCL Context created!\nSee output log for details.");
        txt.setLocalTranslation(5, settings.getHeight() - 5, 0);
        guiNode.attachChild(txt);
        return;
    }
    CommandQueue clQueue = clContext.createQueue();
    StringBuilder str = new StringBuilder();
    str.append("OpenCL Context created:\n  Platform: ").append(clContext.getDevices().get(0).getPlatform().getName()).append("\n  Devices: ").append(clContext.getDevices());
    str.append("\nTests:");
    str.append("\n  Buffers: ").append(testBuffer(clContext, clQueue));
    str.append("\n  Kernel: ").append(testKernel(clContext, clQueue));
    str.append("\n  Images: ").append(testImages(clContext, clQueue));
    clQueue.release();
    BitmapText txt1 = new BitmapText(fnt);
    txt1.setText(str.toString());
    txt1.setLocalTranslation(5, settings.getHeight() - 5, 0);
    guiNode.attachChild(txt1);
    flyCam.setEnabled(false);
    inputManager.setCursorVisible(true);
}
Also used : BitmapText(com.jme3.font.BitmapText) BitmapFont(com.jme3.font.BitmapFont)

Example 5 with Kernel

use of com.jme3.network.kernel.Kernel in project jmonkeyengine by jMonkeyEngine.

the class DefaultServer method addChannel.

@Override
public int addChannel(int port) {
    if (isRunning)
        throw new IllegalStateException("Channels cannot be added once server is started.");
    // Check for consistency with the channels list
    if (channels.size() - CH_FIRST != alternatePorts.size())
        throw new IllegalStateException("Channel and port lists do not match.");
    try {
        int result = alternatePorts.size();
        alternatePorts.add(port);
        Kernel kernel = kernelFactory.createKernel(result, port);
        channels.add(new KernelAdapter(this, kernel, dispatcher, true));
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Error adding channel for port:" + port, e);
    }
}
Also used : IOException(java.io.IOException) Kernel(com.jme3.network.kernel.Kernel) Endpoint(com.jme3.network.kernel.Endpoint)

Aggregations

com.jme3.opencl (com.jme3.opencl)3 IOException (java.io.IOException)3 BitmapFont (com.jme3.font.BitmapFont)2 BitmapText (com.jme3.font.BitmapText)2 KernelException (com.jme3.network.kernel.KernelException)2 Random (java.util.Random)2 Matrix3f (com.jme3.math.Matrix3f)1 Matrix4f (com.jme3.math.Matrix4f)1 Vector2f (com.jme3.math.Vector2f)1 Endpoint (com.jme3.network.kernel.Endpoint)1 Kernel (com.jme3.network.kernel.Kernel)1 DatagramPacket (java.net.DatagramPacket)1 SocketException (java.net.SocketException)1