8000 Make sure, that new Buffer views are used in PrimitiveBlocks from BufferAccess · Issue #368 · imglib/imglib2 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Make sure, that new Buffer views are used in PrimitiveBlocks from BufferAccess #368
Open
@tpietzsch

Description

@tpietzsch

MemCopy implementations that copy from/to Buffers currently use the stateful Buffer APIs, e.g.

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0