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);
}
}
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);
}
}
}
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);
}
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);
}
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);
}
}
Aggregations