Package net.openhft.lang.values

Examples of net.openhft.lang.values.IntValue


                for (int i = 0; i < threads; i++) {
                    final int t = i;
                    futures.add(es.submit(new Runnable() {
                        @Override
                        public void run() {
                            IntValue value = nativeIntValue();
                            StringBuilder sb = new StringBuilder();
                            long next = 50 * 1000 * 1000;
                            // use a factor to give up to 10 digit numbers.
                            int factor = Math.max(1, (int) ((10 * 1000 * 1000 * 1000L - 1) / entries));
                            for (long j = t % independence; j < entries + independence - 1; j += independence) {
                                sb.setLength(0);
                                sb.append("us:");
                                sb.append(j * factor);
                                map.acquireUsing(sb, value);
                                long n = value.addAtomicValue(1);
                                assert n > 0 && n < 1000 : "Counter corrupted " + n;
                                if (t == 0 && j >= next) {
                                    long size = map.longSize();
                                    if (size < 0) throw new AssertionError("size: " + size);
                                    System.out.println(j + ", size: " + size);
View Full Code Here


        final SharedHashMap<IntValue, CharSequence> map = new SharedHashMapBuilder()
                .entries(1000)
                .entries(20000).file(getPersistenceFile()).kClass(IntValue.class).vClass(CharSequence.class).create();

        IntValue$$Native value = new IntValue$$Native();
        value.bytes(new ByteBufferBytes(ByteBuffer.allocateDirect(4)), 0);

        value.setValue(1);
        final String expected = "test";
        map.put(value, expected);

        final CharSequence actual = map.get(value);
        assertEquals(expected, actual);
View Full Code Here

    private SharedHashMap<IntValue, CharSequence> map2;
    private IntValue$$Native value;

    @Before
    public void setup() throws IOException {
        value = new IntValue$$Native();
        value.bytes(new ByteBufferBytes(ByteBuffer.allocateDirect(4)), 0);
        map1 = newTcpSocketShmIntValueString((byte) 1, 8076, new InetSocketAddress("localhost", 8077));
        map2 = newTcpSocketShmIntValueString((byte) 2, 8077);
    }
View Full Code Here

TOP

Related Classes of net.openhft.lang.values.IntValue

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.