Package uk.ac.uea.threadr.internal.vmhandler

Examples of uk.ac.uea.threadr.internal.vmhandler.VMWrapper


    ReferenceVMTask task = new ReferenceVMTask();
    int[] reference = Arrays.copyOf(task.getData(), ReferenceTask.SIZE);
   
    Arrays.sort(reference);
   
    VMWrapper newVM = new VMWrapper(task);
    try {
      AbstractReturnType<?> returned = newVM.call(); // run the task.
      assertArrayEquals("Result different from reference", reference,
          (int[])returned.getResult());
    } catch (Exception e) {
      fail("Error executing new Virtual Machine");
    }
View Full Code Here


  @Test
  public final void testEquality() {
       
    ParallelTask task1 = new ReferenceTask();
   
    VMWrapper wrapper1Task1 = new VMWrapper(task1);
    VMWrapper wrapper2Task1 = new VMWrapper(task1);
    VMWrapper wrapper1Task2 = new VMWrapper(new ParallelTask() {     
      @Override
      public AbstractReturnType<?> call() {
        return null; // Don't do anything.
      }
    });
   
    /* Test various equality comparisons to ensure equals() works. */
    assertTrue("Same wrapper objects different.",
        wrapper1Task1.equals(wrapper1Task1));
    assertTrue("Same task wrappers different.",
        wrapper1Task1.equals(wrapper2Task1));
    assertTrue("Same task wrappers different reveresed.",
        wrapper2Task1.equals(wrapper1Task1));
    assertFalse("Different task wrappers equal.",
        wrapper1Task2.equals(wrapper1Task1));
    assertFalse("Different task wrappers equal reveresed.",
        wrapper1Task1.equals(wrapper1Task2));
  }
View Full Code Here

      final ExecutorService executor,
      final ParallelTask task) {
   
    Future<AbstractReturnType<?>> result = null;
    /* Stick the task inside a VMWrapper and send it to be executed. */
    VMWrapper newVM = null;
    if (vmParameters != null
        && vmParameters.length > 0) {
      /* If there are custom parameters, pass them to the VM instance. */
      newVM = new VMWrapper(task, vmParameters);
    } else {
      /* Otherwise, just create the instance. */
      newVM = new VMWrapper(task);
    }
   
    /* Try and execute the provided task in a new VM. */
    result = executor.submit(newVM);
   
View Full Code Here

TOP

Related Classes of uk.ac.uea.threadr.internal.vmhandler.VMWrapper

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.