Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NeoSuit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Christian Wulf
NeoSuit
Commits
39dbf2d0
Commit
39dbf2d0
authored
9 years ago
by
Daniel Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
added demo code
parent
0b2acdff
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
Initial gui, closes #5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
NeoSuit/src/main/java/ui/MainScene.java
+23
-2
23 additions, 2 deletions
NeoSuit/src/main/java/ui/MainScene.java
with
23 additions
and
2 deletions
NeoSuit/src/main/java/ui/MainScene.java
+
23
−
2
View file @
39dbf2d0
...
...
@@ -18,8 +18,28 @@ public class MainScene extends Control {
TextArea
parallelCodeField
;
private
void
setDemoText
()
{
currentCodeField
.
setText
(
"# TODO: Put non parallel some code here"
);
parallelCodeField
.
setText
(
"# TODO: put some parallel code here"
);
String
current
=
"\n"
+
"public List<Output> processInputs(List<Input> inputs) throws InterruptedException, ExecutionException {\n"
+
"\t List<Output> outputs = new ArrayList<Output>();\n"
+
"\t for (Input input : inputs) {\n"
+
"\t\t Output result = 42; /* process your input here and compute the output */ \n"
+
"\t\t outputs.add(result);\n"
+
"\t } \n"
+
"\t return outputs; \n"
+
"}"
;
String
parallel
=
"\n"
+
"public List<Output> processInputs(List<Input> inputs) throws InterruptedException, ExecutionException {\n"
+
"\t int threads = Runtime.getRuntime().availableProcessors();\n"
+
"\t ExecutorService service = Executors.newFixedThreadPool(threads);\n"
+
"\n"
+
"\t List<Future<Output>> futures = new ArrayList<Future<Output>>();\n"
+
"\t for (final Input input : inputs) {\n"
+
"\t\t Callable<Output> callable = new Callable<Output>() {\n"
+
"\t\t\t public Output call() throws Exception {\n"
+
"\t\t\t\t Output output = new Output();\n"
+
"\t\t\t\t // process your input here and compute the output\n"
+
"\t\t\t\t return output;\n"
+
"\t\t\t }\n"
+
"\t\t };\n"
+
"\t\t futures.add(service.submit(callable));\n"
+
"\t }\n"
+
"\t service.shutdown();\n"
+
"\n"
+
"\t List<Output> outputs = new ArrayList<Output>();\n"
+
"\t for (Future<Output> future : futures) {\n"
+
"\t\t outputs.add(future.get());\n"
+
"\t } \n"
+
"\t return outputs; \n"
+
"}"
;
currentCodeField
.
setText
(
current
);
parallelCodeField
.
setText
(
parallel
);
}
@FXML
...
...
@@ -36,6 +56,7 @@ public class MainScene extends Control {
@FXML
private
void
handleStartAction
(
ActionEvent
event
)
{
setDemoText
();
progressBar
.
setProgress
(
0.9
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment