Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BigDataViewer_Core_Extension
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BioinformaticDataCompression
BigDataViewer_Core_Extension
Commits
1d74becd
Commit
1d74becd
authored
10 years ago
by
Tobias Pietzsch
Browse files
Options
Downloads
Patches
Plain Diff
multithreaded float opening: use Void Callables, shutdown() ExecutorService
parent
6f25db81
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/src/main/java/bdv/img/hdf5/Hdf5ImageLoader.java
+9
-8
9 additions, 8 deletions
core/src/main/java/bdv/img/hdf5/Hdf5ImageLoader.java
with
9 additions
and
8 deletions
core/src/main/java/bdv/img/hdf5/Hdf5ImageLoader.java
+
9
−
8
View file @
1d74becd
...
...
@@ -377,9 +377,9 @@ public class Hdf5ImageLoader extends AbstractViewerImgLoader< UnsignedShortType,
// set up executor service
final
int
numProcessors
=
Runtime
.
getRuntime
().
availableProcessors
();
final
ExecutorService
taskExecutor
=
Executors
.
newFixedThreadPool
(
numProcessors
);
final
ArrayList
<
Callable
<
Boolean
>
>
tasks
=
new
ArrayList
<
Callable
<
Boolean
>
>();
final
ArrayList
<
Callable
<
Void
>
>
tasks
=
new
ArrayList
<
Callable
<
Void
>
>();
// set up all t
hread
s
// set up all t
ask
s
final
int
numPortions
=
numProcessors
*
2
;
final
long
threadChunkSize
=
floatImg
.
size
()
/
numPortions
;
final
long
threadChunkMod
=
floatImg
.
size
()
%
numPortions
;
...
...
@@ -392,24 +392,24 @@ public class Hdf5ImageLoader extends AbstractViewerImgLoader< UnsignedShortType,
// the last thread may has to run longer if the number of pixels cannot be divided by the number of threads
final
long
loopSize
=
(
portionID
==
numPortions
-
1
)
?
threadChunkSize
+
threadChunkMod
:
threadChunkSize
;
tasks
.
add
(
new
Callable
<
Boolean
>()
tasks
.
add
(
new
Callable
<
Void
>()
{
@Override
public
Boolean
call
()
throws
Exception
public
Void
call
()
throws
Exception
{
final
Cursor
<
UnsignedShortType
>
in
=
Views
.
iterable
(
ushortImg
).
localizingCursor
();
final
RandomAccess
<
FloatType
>
out
=
floatImg
.
randomAccess
();
in
.
jumpFwd
(
startPosition
);
for
(
long
j
=
0
;
j
<
loopSize
;
++
j
)
{
final
UnsignedShortType
vin
=
in
.
next
();
out
.
setPosition
(
in
);
out
.
get
().
set
(
vin
.
getRealFloat
()
);
}
return
true
;
return
null
;
}
});
}
...
...
@@ -418,6 +418,7 @@ public class Hdf5ImageLoader extends AbstractViewerImgLoader< UnsignedShortType,
{
// invokeAll() returns when all tasks are complete
taskExecutor
.
invokeAll
(
tasks
);
taskExecutor
.
shutdown
();
}
catch
(
final
InterruptedException
e
)
{
...
...
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