Package pt.ul.armus.edgebuffer

Examples of pt.ul.armus.edgebuffer.TaskHandle


   * @see pt.ul.jarmus.JArmusFacade#afterTask()
   */
  @Override
  public void afterTask() {
    ResourceManager task = resourceManager.get();
    TaskHandle oldTask = task.endTask();
    verifier.getBuffer().destroy(oldTask);
  }
View Full Code Here


   * Finish the context. This should be called after the task executes a task.
   * @return
   */
  public TaskHandle endTask() {
    // discard current state and revert to the previous state
    TaskHandle oldHandle = handle;
    State state = stack.pop();
    this.phases = state.res;
    this.handle = state.handle;
    return oldHandle;
  }
View Full Code Here

    ver = new JArmusControllerImpl(strat);   
  }

  @Test
  public void threadRegisteredPhase1() throws InstantiationException, IllegalAccessException {
    TaskHandle task = mock(TaskHandle.class);
    EdgeBuffer buffer = mock(EdgeBuffer.class);
    when(strat.getBuffer()).thenReturn(buffer);
    when(buffer.createHandle()).thenReturn(task);
    assertEquals(1, ver.getPhase(Thread.currentThread()));
  }
View Full Code Here

    assertEquals(1, ver.getPhase(Thread.currentThread()));
  }

  @Test
  public void ensureThreadIsRegistered() throws InstantiationException, IllegalAccessException {
    TaskHandle task = mock(TaskHandle.class);
    EdgeBuffer buffer = mock(EdgeBuffer.class);
    when(strat.getBuffer()).thenReturn(buffer);
    when(buffer.createHandle()).thenReturn(task);
    ver.ensureRegistered(Thread.currentThread());
  }
View Full Code Here

    ver.ensureRegistered(Thread.currentThread());
  }

  @Test
  public void testThreadIsRegistered() throws InstantiationException, IllegalAccessException {
    TaskHandle task = mock(TaskHandle.class);
    EdgeBuffer buffer = mock(EdgeBuffer.class);
    when(strat.getBuffer()).thenReturn(buffer);
    when(buffer.createHandle()).thenReturn(task);
    assertTrue(ver.isRegistered(Thread.currentThread()));
  }
View Full Code Here

    assertTrue(ver.isRegistered(Thread.currentThread()));
  }
 
  @Test
  public void testThreadIsRegisteredBeginTask() throws InstantiationException, IllegalAccessException {
    TaskHandle task = mock(TaskHandle.class);
    EdgeBuffer buffer = mock(EdgeBuffer.class);
    when(strat.getBuffer()).thenReturn(buffer);
    when(buffer.createHandle()).thenReturn(task);
   
    ver.beforeTask();
View Full Code Here

public class ResourceManagerTest {
  private static final Object synch = new Object();
 
  @Test
  public void testIsRegistered() {
    TaskHandle handle = mock(TaskHandle.class);
    ResourceManager m = new ResourceManager(handle);
    m.register(synch, 0);
    assertTrue(m.isRegistered(synch));
  }
View Full Code Here

    assertTrue(m.isRegistered(synch));
  }

  @Test
  public void testDeregister() {
    TaskHandle handle = mock(TaskHandle.class);
    ResourceManager m = new ResourceManager(handle);
    m.register(synch, 0);
    m.deregister(synch);
    assertFalse(m.isRegistered(synch));
  }
View Full Code Here

    assertFalse(m.isRegistered(synch));
  }

  @Test
  public void advanceRegistered() {
    TaskHandle handle = mock(TaskHandle.class);
    ResourceManager m = new ResourceManager(handle);
    m.register(synch, 0);
    assertEquals(0, m.advance(synch));
  }
View Full Code Here

    assertEquals(0, m.advance(synch));
  }

  @Test
  public void advanceUnregistered() {
    TaskHandle handle = mock(TaskHandle.class);
    ResourceManager m = new ResourceManager(handle);
    try {
      m.advance(synch);
      fail("Should throw an exception.");
    } catch (IllegalStateException e) {
View Full Code Here

TOP

Related Classes of pt.ul.armus.edgebuffer.TaskHandle

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.