Package com.esotericsoftware.kryo

Examples of com.esotericsoftware.kryo.Kryo


  public int size () {
    return queue.size();
  }

  public Kryo borrow () {
    Kryo res;
    if((res = queue.poll()) != null) {
      return res;
    }
    return factory.create();
  }
View Full Code Here


  public void release (Kryo kryo) {
    queue.offer(kryo);
  }

  public <T> T run(KryoCallback<T> callback) {
    Kryo kryo = borrow();
    try {
      return callback.execute(kryo);
    } finally {
      release(kryo);
    }
View Full Code Here

  private void runWithPool (final KryoPool.Builder builder, final int runCount, final int iterCount, boolean outputResults) throws Exception {
    final KryoPool pool = builder.build();
    run("With pool " + builder.toString(), new Runnable() {
      @Override
      public void run () {
        Kryo kryo = pool.borrow();
        pool.release(kryo);
      }
    }, runCount, iterCount, outputResults);
  }
View Full Code Here

    return ((KryoPoolQueueImpl)pool).size();
  }

  @Test
  public void getShouldReturnAvailableInstance() {
    Kryo kryo = pool.borrow();
    pool.release(kryo);
    assertTrue(kryo == pool.borrow());
  }
View Full Code Here

  }

  @Test
  public void releaseShouldAddKryoToPool() {
    assertEquals(0, size());
    Kryo kryo = pool.borrow();
    pool.release(kryo);
    assertEquals(1, size());
  }
View Full Code Here

  }

  @Test
  public void testSize() {
    assertEquals(0, size());
    Kryo kryo1 = pool.borrow();
    assertEquals(0, size());
    Kryo kryo2 = pool.borrow();
    assertFalse(kryo1 == kryo2);
    pool.release(kryo1);
    assertEquals(1, size());
    pool.release(kryo2);
    assertEquals(2, size());
View Full Code Here

public class KryoSerializer implements ObjectSerializer<MediaContent> {
  protected Kryo kryo;
  protected ObjectBuffer objectBuffer;

  public KryoSerializer () {
    kryo = new Kryo();
    kryo.register(ArrayList.class);
    kryo.register(MediaContent.class);
    kryo.register(Media.Player.class);
    kryo.register(Media.class);
    kryo.register(Image.Size.class);
View Full Code Here

*
* @author pron
*/
public final class KryoUtil {
    public static Kryo newKryo() {
        Kryo kryo = new ReplaceableObjectKryo();

        kryo.setRegistrationRequired(false);
        kryo.setInstantiatorStrategy(new SerializingInstantiatorStrategy());
        registerCommonClasses(kryo);
        return kryo;
    }
View Full Code Here

    return buffer.toString();
  }

  public String toKryo() {
    Output out = new Output(4 * 1024, 10 * 1024 * 1024);
    new Kryo().writeObject(out, this);
    out.close();
    return Base64.encodeBase64String(out.toBytes());
  }
View Full Code Here

    return Base64.encodeBase64String(out.toBytes());
  }

  static SearchArgument fromKryo(String value) {
    Input input = new Input(Base64.decodeBase64(value));
    return new Kryo().readObject(input, SearchArgumentImpl.class);
  }
View Full Code Here

TOP

Related Classes of com.esotericsoftware.kryo.Kryo

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.