Package cl.niclabs.skandium.system

Examples of cl.niclabs.skandium.system.Task


  public Future<R> input(P param){
   
        StackBuilder builder = new StackBuilder();
        skeleton.accept(builder);
       
        Task task = new Task(param, builder.stack, executor);
    this.executor.execute(task);
   
    return (Future<R>)task.getFuture();
  }
View Full Code Here


    return head;
  }
 
  Task registerReceivedTask(TaskHead head, SCTaskExecutor executor) {
   
    Task task = new Task(head.getData(), head.getStack(), executor);
    received.put(task.id, head);
    return task;
  }
View Full Code Here

    return task;
  }
 
  Task eraseTransmittedTask(TaskHead head) {
   
    Task task =  transmitted.remove(head.getOriginId());
    if(task != null) {
      task.setP(head.getData());
    }
   
    return task;
  }
View Full Code Here

      Skeleton<P, R> skeleton, P param) {
   
    StackBuilder builder = new StackBuilder();
    skeleton.accept(builder);
   
    Task task = new Task(param, builder.stack, executor);
    if(VERBOSE)
      System.out.println("Task from user accepted on host " + hostname);
   
    executor.execute(task);
  }
View Full Code Here

 
  @Override
  public void transmitTask(TaskHead head) {
   
    try {
      Task task = registry.registerReceivedTask(head, executor);
      if(VERBOSE) System.out.println("Task received on host " + hostname);
      executor.execute(task);
    }
    catch(Exception e) {
      e.printStackTrace();
View Full Code Here

  }

  @Override
  public void receiveResult(TaskHead head) {
   
    Task task = registry.eraseTransmittedTask(head);
   
    if(task == null) {
      System.err.println("Received result of non transmitted task or " +
          "already received result");
      (new NullPointerException()).printStackTrace();
      return;
    }
   
    if(VERBOSE) System.out.println("Result received on host " + hostname);
   
    if( !task.isRoot() ) {
      task.notifyParent();
      return;
    }
   
    returnFinishedTaskResult(task);
  }
View Full Code Here

  @Override
  public void execute(Runnable r) {
   
    if( !(r instanceof Task) ) return;
   
    Task task = (Task) r;
    try {
      if( condition.condition(getQueue().size(), getMaximumPoolSize())
          && sc.lookupFc("sct") != null) {
       
        sc.delegateTask(task);
View Full Code Here

  protected void afterExecute(Runnable r, Throwable t) {
   
    if(t != null) t.printStackTrace();
    if( !(r instanceof Task) ) return;
   
    Task task = (Task) r;
   
    synchronized(task) {
   
      if( !task.isFinished() )
        return;
 
      if( ! task.isNotified() ) {
       
        if( !task.isRoot() ) {
          task.notifyParent();
        }
        else {
          sc.returnFinishedTaskResult(task);
        }
       
        task.setAsNotified();
      }
    }
  }
View Full Code Here

TOP

Related Classes of cl.niclabs.skandium.system.Task

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.