Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run a task now. #421

Closed
gallandarakhneorg opened this issue Jun 20, 2016 · 1 comment · Fixed by #540
Closed

Run a task now. #421

gallandarakhneorg opened this issue Jun 20, 2016 · 1 comment · Fixed by #540

Comments

@gallandarakhneorg
Copy link
Member

gallandarakhneorg commented Jun 20, 2016

What is the best practice for running the following parallel task:

while (true) {
    var server : Socket = serverSocket.accept();
    var in = new DataInputStream(server.getInputStream());
    eventListener.messageReceived(in.readUTF());
    server.close();
}

Use of in or every seems to not be the good semantic from my point of view.

Perhaps functions are missed in the Shedules capacity:

def execute(task : AgentTask = null, code : (Agent) => void) : AgentTask

We may also consider to propose an "infinite loop" running mechanism for ensuring thread balancing:

def loop(task : AgentTask = null, code : (Agent) => void) : AgentTask

This function will create the runnable like this:

executorService.submit( () -> {
   while (true) {
      code;
      Thread.yield();
   }
});
@gallandarakhneorg
Copy link
Member Author

Issue #243 may be solved by the current issue with the introduction of:

def loop(task : AgentTask = null, delayBetweenRuns : long = 0, code : (Agent) => void) : AgentTask

@gallandarakhneorg gallandarakhneorg self-assigned this Nov 21, 2016
gallandarakhneorg added a commit that referenced this issue Nov 21, 2016
see #421

Signed-off-by: Stéphane Galland <galland@arakhne.org>
gallandarakhneorg added a commit that referenced this issue Nov 21, 2016
see #243
see #421

Signed-off-by: Stéphane Galland <galland@arakhne.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant