diff options
author | Martin Sustrik <sustrik@fastmq.commkdir> | 2009-09-05 09:30:12 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@fastmq.commkdir> | 2009-09-05 09:30:12 +0200 |
commit | 67253f3186488db93dee23bd9194419f58f0b1d3 (patch) | |
tree | e5e3ed1c3f1d4b2cf5f9a1b81f869a9bd9f14c06 /java/org | |
parent | 63b56d7fb38624c32111f9188d54b6fefb10a0e5 (diff) |
Java perf tests added
Diffstat (limited to 'java/org')
-rw-r--r-- | java/org/zmq/Context.java | 3 | ||||
-rw-r--r-- | java/org/zmq/Message.java | 66 | ||||
-rw-r--r-- | java/org/zmq/Socket.java | 42 |
3 files changed, 23 insertions, 88 deletions
diff --git a/java/org/zmq/Context.java b/java/org/zmq/Context.java index 8bc4d57..c63ef60 100644 --- a/java/org/zmq/Context.java +++ b/java/org/zmq/Context.java @@ -34,6 +34,9 @@ public class Context { construct (appThreads, ioThreads); } + /** + * Internal function. Do not use directly! + */ public native long createSocket (int type); /** Initialize the JNI interface */ diff --git a/java/org/zmq/Message.java b/java/org/zmq/Message.java deleted file mode 100644 index 3691410..0000000 --- a/java/org/zmq/Message.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - Copyright (c) 2007-2009 FastMQ Inc. - - This file is part of 0MQ. - - 0MQ is free software; you can redistribute it and/or modify it under - the terms of the Lesser GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - 0MQ is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - Lesser GNU General Public License for more details. - - You should have received a copy of the Lesser GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. -*/ - -package org.zmq; - -public class Message { - static { - System.loadLibrary("jzmq"); - } - - /** - * Class constructor. - */ - public Message () { - construct (); - } - - public Message (byte [] payload) { - constructWithData (payload); - } - - /** - * Get message payload. - */ - public native byte [] getMsgPayload (); - - /** - * Get message type. - */ - public native int getMsgType (); - - /** - * Get low-level message handler. - */ - public long getMsgHandle () { - return msgHandle; - } - - /** Initialize the JNI interface */ - protected native void construct (); - - protected native void constructWithData (byte [] payload); - - /** Free resources used by JNI driver. */ - protected native void finalize (); - - /** Opaque data used by JNI driver. */ - private long msgHandle; -} - diff --git a/java/org/zmq/Socket.java b/java/org/zmq/Socket.java index 3bfbfec..832467f 100644 --- a/java/org/zmq/Socket.java +++ b/java/org/zmq/Socket.java @@ -19,26 +19,26 @@ package org.zmq; -public class Socket { +public class Socket +{ + static { System.loadLibrary("jzmq"); } - public static final int ZMQ_MAX_VSM_SIZE = 30; - - public static final int ZMQ_GAP = 1; + public static final int NOBLOCK = 1; - public static final int ZMQ_DELIMITER = 31; + public static final int NOFLUSH = 2; - public static final int ZMQ_NOBLOCK = 1; + public static final int P2P = 0; - public static final int ZMQ_NOFLUSH = 2; + public static final int PUB = 1; - public static final int ZMQ_P2P = 0; + public static final int SUB = 2; - public static final int ZMQ_PUB = 1; + public static final int REQ = 3; - public static final int ZMQ_SUB = 2; + public static final int REP = 4; /** * Class constructor. @@ -47,7 +47,6 @@ public class Socket { * @param type */ public Socket (Context context, int type) { - ctx = context; construct (context, type); } @@ -94,37 +93,39 @@ public class Socket { public native void setIdentity (String identity); /** + * Bind to network interface. Start listening for new connections. + * * @param addr */ public native void bind (String addr); /** - * Connect. + * Connect to remote application. * * @param addr */ public native void connect (String addr); /** - * Send. + * Send the message. * - * @param message - * @param block + * @param msg + * @param flags */ - public native int send (Message msg, long flags); + public native boolean send (byte [] msg, long flags); /** - * Flush all messages sent with flush flag false down the stream. + * Flush the messages down the stream. */ public native void flush (); /** * Receive message. * - * @param block + * @param flags * @return */ - public native Message recv (long flags); + public native byte [] recv (long flags); /** Initialize JNI driver */ protected native void construct (Context context, int type); @@ -132,9 +133,6 @@ public class Socket { /** Free all resources used by JNI driver. */ protected native void finalize (); - /** Keep reference to ZMQ context so it is not garbage collected */ - private Context ctx; - /** Opaque data used by JNI driver. */ private long socketHandle; |