Examples of TaskGroup


Examples of kilim.TaskGroup

import kilim.Task;
import kilim.TaskGroup;

public class Group {
    public static void main(String[] args) {
        TaskGroup tg = new TaskGroup();
        tg.add(new GroupTask().start());
        tg.add(new GroupTask().start());
        tg.joinb();
        System.exit(0);
    }
View Full Code Here

Examples of org.apache.pivot.util.concurrent.TaskGroup

                System.out.println("FAILED: " + task.getFault());
                notify();
            }
        };

        TaskGroup taskGroup = new TaskGroup();

        SleepTask task1 = new SleepTask(2000);
        taskGroup.add(task1);

        SleepTask task2 = new SleepTask(500);
        taskGroup.add(task2);

        SleepTask task3 = new SleepTask(1000);
        taskGroup.add(task3);

        synchronized (taskListener) {
            taskGroup.execute(taskListener);

            try {
                taskListener.wait();
            } catch (InterruptedException exception) {
            }
View Full Code Here

Examples of org.apache.pivot.util.concurrent.TaskGroup

                System.out.println("FAILED: " + task.getFault());
                notify();
            }
        };

        TaskGroup taskGroup = new TaskGroup();

        SleepTask task1 = new SleepTask(500);
        taskGroup.add(task1);

        SleepTask task2 = new SleepTask(1000);
        taskGroup.add(task2);

        SleepTask task3 = new SleepTask(2000);
        taskGroup.add(task3);

        synchronized (taskListener) {
            taskGroup.execute(taskListener);

            try {
                taskListener.wait();
            } catch (InterruptedException exception) {
                // empty block
View Full Code Here

Examples of org.apache.pivot.util.concurrent.TaskGroup

                System.out.println("FAILED: " + task.getFault());
                notify();
            }
        };

        TaskGroup taskGroup = new TaskGroup();

        SleepTask task1 = new SleepTask(500);
        taskGroup.add(task1);

        SleepTask task2 = new SleepTask(1000);
        taskGroup.add(task2);

        SleepTask task3 = new SleepTask(2000);
        taskGroup.add(task3);

        synchronized (taskListener) {
            taskGroup.execute(taskListener);

            try {
                taskListener.wait();
            } catch (InterruptedException exception) {
            }
View Full Code Here

Examples of org.apache.pivot.util.concurrent.TaskGroup

    @Test
    public void basicTest() throws SerializationException {
        final BasicAuthentication authentication = new BasicAuthentication("foo", "bar");

        TaskGroup queryGroup = new TaskGroup();

        // GET
        final GetQuery getQuery = new GetQuery(HOSTNAME, PORT, PATH, SECURE);
        getQuery.getParameters().put("a", "b");
        getQuery.setSerializer(new BinarySerializer());
        getQuery.getRequestHeaders().add("bar", "hello");
        getQuery.getRequestHeaders().add("bar", "world");
        authentication.authenticate(getQuery);
        queryGroup.add(getQuery);

        // POST
        final PostQuery postQuery = new PostQuery(HOSTNAME, PORT, PATH, SECURE);
        authentication.authenticate(postQuery);
        postQuery.setValue(JSONSerializer.parseList("[1, 2, 3]"));
        queryGroup.add(postQuery);

        // PUT
        final PutQuery putQuery = new PutQuery(HOSTNAME, PORT, PATH, SECURE);
        authentication.authenticate(putQuery);
        putQuery.setValue(JSONSerializer.parseMap("{a:100, b:200, c:300}"));
        queryGroup.add(putQuery);

        // POST
        final DeleteQuery deleteQuery = new DeleteQuery(HOSTNAME, PORT, PATH, SECURE);
        authentication.authenticate(deleteQuery);
        queryGroup.add(deleteQuery);

        queryGroup.execute(new TaskListener<Void>() {
            @SuppressWarnings("unchecked")
            @Override
            public synchronized void taskExecuted(Task<Void> task) {
                Dictionary<String, Object> result = (Dictionary<String, Object>)getQuery.getResult();

                System.out.println("GET result: "
                    + "username: " + result.get("username") + ", "
                    + "pathInfo: " + result.get("pathInfo") + ", "
                    + "queryString: " + result.get("queryString") + ", "
                    + "status: " + getQuery.getStatus());

                QueryDictionary responseHeaders = getQuery.getResponseHeaders();
                for (String headerName : responseHeaders) {
                    System.out.print(headerName + "=");

                    for (int i = 0, n = responseHeaders.getLength(headerName); i < n; i++) {
                        System.out.print(responseHeaders.get(headerName, i) + ";");
                    }

                    System.out.print("\n");
                }
                System.out.println("GET fault: " + getQuery.getFault());

                System.out.println("POST result: " + task.getResult());
                System.out.println("POST fault: " + postQuery.getFault());

                System.out.println("PUT fault: " + putQuery.getFault());
                System.out.println("DELETE fault: " + deleteQuery.getFault());
            }

            @Override
            public synchronized void executeFailed(Task<Void> task) {
                // No-op; task groups don't fail
            }
        });

        synchronized(queryGroup) {
            if (queryGroup.isPending()) {
                try {
                    queryGroup.wait(10000);
                } catch(InterruptedException exception) {
                    throw new RuntimeException(exception);
                }
            }
        }
View Full Code Here

Examples of org.eclipse.ui.internal.cheatsheets.composite.model.TaskGroup

  }

  private AbstractTask createTask(String nodeKind, CompositeCheatSheetModel model, String kind, String id, String name) {
    AbstractTask task;
    if (ICompositeCheatsheetTags.TASK_GROUP.equals(nodeKind)) {
      task = new TaskGroup(model, id, name, kind);
    } else {
      task = new EditableTask(model, id, name, kind);
    }
    task.setCompletionMessage(Messages.COMPLETED_TASK);
    return task;
View Full Code Here

Examples of org.encog.engine.concurrency.TaskGroup

  public void process() {
    Object task;

    this.totalTasks = loadWorkload();
    int currentTask = 0;
    TaskGroup group = EngineConcurrency.getInstance().createTaskGroup();

    while (((task = requestNextTask()) != null) && !shouldStop) {
      currentTask++;
      final JobUnitContext context = new JobUnitContext();
      context.setJobUnit(task);
      context.setOwner(this);
      context.setTaskNumber(currentTask);

      final JobUnitWorker worker = new JobUnitWorker(context);
      EngineConcurrency.getInstance().processTask(worker, group);
    }

    group.waitForComplete();

    EngineConcurrency.getInstance().checkError();
  }
View Full Code Here

Examples of org.encog.engine.concurrency.TaskGroup

    this.workers[0].getNetwork().clearContext();
    this.totalError = 0;

    if (this.workers.length > 1) {

      final TaskGroup group = EngineConcurrency.getInstance()
          .createTaskGroup();

      for (final FlatGradientWorker worker : this.workers) {
        EngineConcurrency.getInstance().processTask(worker, group);
      }

      group.waitForComplete();
    } else {
      this.workers[0].run();
    }

    this.currentError = this.totalError / this.workers.length;
View Full Code Here

Examples of org.encog.util.concurrency.TaskGroup

    int offspringIndex = getPopulation().getPopulationSize()
        - offspringCount;
    final int matingPopulationSize = (int) (getPopulation()
        .getPopulationSize() * getMatingPopulation());

    final TaskGroup group = EngineConcurrency.getInstance()
        .createTaskGroup();

    // mate and form the next generation
    for (int i = 0; i < countToMate; i++) {
      final Genome mother = getPopulation().getGenomes().get(i);
      final int fatherInt = (int) (Math.random() * matingPopulationSize);
      final Genome father = getPopulation().getGenomes().get(fatherInt);
      final Genome child1 = getPopulation().getGenomes().get(
          offspringIndex);
      final Genome child2 = getPopulation().getGenomes().get(
          offspringIndex + 1);

      final MateWorker worker = new MateWorker(mother, father, child1,
          child2);

      if( this.isMultiThreaded() ) {
        EngineConcurrency.getInstance().processTask(worker, group);
      } else {
        worker.run();
      }
     
      offspringIndex += 2;
    }

    if( this.isMultiThreaded() ) {
      group.waitForComplete();
    }

    // sort the next generation
    getPopulation().sort();
  }
View Full Code Here

Examples of org.encog.util.concurrency.TaskGroup

    Object task;

    this.running = true;
    this.totalTasks = loadWorkload();
    int currentTask = 0;
    TaskGroup group = EngineConcurrency.getInstance().createTaskGroup();

    while (((task = requestNextTask()) != null) && !shouldStop) {
      currentTask++;
      final JobUnitContext context = new JobUnitContext();
      context.setJobUnit(task);
      context.setOwner(this);
      context.setTaskNumber(currentTask);

      final JobUnitWorker worker = new JobUnitWorker(context);
      EngineConcurrency.getInstance().processTask(worker, group);
    }

    group.waitForComplete();
    this.running = false;
    EngineConcurrency.getInstance().checkError();   
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.