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

what is the function of scheduler package? #125

Open
CallumWang opened this issue Sep 20, 2018 · 1 comment
Open

what is the function of scheduler package? #125

CallumWang opened this issue Sep 20, 2018 · 1 comment
Labels

Comments

@CallumWang
Copy link

Hello:
I found the schedular usage in Matcher.java. However, it seems that it is related to something about Cocurrent. What is the meaning of it in this "for block".

for (final MatcherCandidate predecessor : predecessors.two()) {
            scheduler.spawn(new Task() {
                @Override
               //something to run.
                }
            });
        }

If I don't use the schedular,what will happen?Does it make any different?
Looking forward to your reply.
Thanks a lot.

@smattheis
Copy link

smattheis commented Sep 23, 2018

The scheduler package is for parallelization of route computations. Since we usually have some number, say n, of matching candidates for each position measurement, we must calculate approximagely n^2 routes. The route computation is a single-source-multiple-target step such that we still have n such computations which we can parallelize here. Note, we have here a simple work-stealing adaptation implemented, which is the scheduler package, because thread pools of the JRE are AFAIK not designed for stream workloads, i.e., there is NO guarantee on the order of processing like a FIFO order such that there is no guarantee that one job finishes if you consistently add more jobs in a stream processing fashion.
To answer your question more precisely, for each predecessor we spawn a task that does the single-source-multiple-target computation where tasks may be executed in parallel with respect to the number of worker threads or processor cores we have available. This is similar to: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ForkJoinPool.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants