42 |
|
|
43 |
abstract class DirectByteBufferImpl extends ByteBuffer |
abstract class DirectByteBufferImpl extends ByteBuffer |
44 |
{ |
{ |
45 |
/** The owner is used to keep alive the object that actually owns the |
/** |
46 |
* memory. There are three possibilities: |
* The owner is used to keep alive the object that actually owns the |
47 |
* 1) owner == this: We allocated the memory and we should free it, |
* memory. There are three possibilities: |
48 |
* but *only* in finalize (if we've been sliced |
* 1) owner == this: We allocated the memory and we should free it, |
49 |
* other objects will also have access to the |
* but *only* in finalize (if we've been sliced |
50 |
* memory). |
* other objects will also have access to the |
51 |
* 2) owner == null: The byte buffer was created thru |
* memory). |
52 |
* JNI.NewDirectByteBuffer. The JNI code is |
* 2) owner == null: The byte buffer was created thru |
53 |
* responsible for freeing the memory. |
* JNI.NewDirectByteBuffer. The JNI code is |
54 |
* 3) owner == some other object: The other object allocated the |
* responsible for freeing the memory. |
55 |
* memory and should free it. |
* 3) owner == some other object: The other object allocated the |
56 |
*/ |
* memory and should free it. |
57 |
|
*/ |
58 |
private final Object owner; |
private final Object owner; |
59 |
|
|
60 |
final RawData address; |
final RawData address; |
61 |
|
|
62 |
final static class ReadOnly extends DirectByteBufferImpl |
static final class ReadOnly extends DirectByteBufferImpl |
63 |
{ |
{ |
64 |
ReadOnly(Object owner, RawData address, |
ReadOnly(Object owner, RawData address, |
65 |
int capacity, int limit, |
int capacity, int limit, |
84 |
} |
} |
85 |
} |
} |
86 |
|
|
87 |
final static class ReadWrite extends DirectByteBufferImpl |
static final class ReadWrite extends DirectByteBufferImpl |
88 |
{ |
{ |
89 |
ReadWrite(int capacity) |
ReadWrite(int capacity) |
90 |
{ |
{ |