-
Notifications
You must be signed in to change notification settings - Fork 95
Open
Description
MemCopy
implementations that copy from/to Buffer
s currently use the stateful Buffer
APIs, e.g.
imglib2/src/main/java/net/imglib2/blocks/MemCopy.java
Lines 477 to 484 in 4f41d20
class MemCopyByteBufferToArray implements MemCopy< ByteBuffer, byte[] > | |
{ | |
@Override | |
public void copyForward( final ByteBuffer src, final int srcPos, final byte[] dest, final int destPos, final int length ) | |
{ | |
src.position( srcPos ); | |
src.get( dest, destPos, length ); | |
} |
To make sure this works in multi-threaded scenarios, new Buffer
views should be used in every PrimitiveBlocks
instance.
For example, this
final S src = ( S ) ( ( ArrayDataAccess< ? > ) cellAccess.get().getData() ).getCurrentStorageArray(); |
should be something like
final S src = ( S ) ( ( ArrayDataAccess< ? > ) cellAccess.get().getData().createView( this ) ).getCurrentStorageArray();
Alternatively, we should make sure that createView()
is called when getting the BufferAccess
from an image. (For example, for ArrayImg
that should be already the case.)
Even better would be to move to Java 9+, where absolute bulk put/get methods are available in Buffer
and we can avoid the stateful API in MemCopy
.
Metadata
Metadata
Assignees
Labels
No labels