You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Andrew Zhang <zh...@gmail.com> on 2006/07/03 05:13:56 UTC

[classlib][nio] [question] Synchronization issue on MappedByteBuffer ?

Hello everyone,

I noticed there are several FIXMEs in MappedByteBufferAdapter.java, which
are related to synchronization issue.

Following FIXME is for getChar() method:

// FIXME Need synchronization as far as the update of this.position is
concerned of the following methods? Spec does not say whether
MappedByteBuffer is thread safe. It is the decision we should make.

I read through MappedByteBuffer javadoc, and didn't find any description
about concurrent & synchronization. The spec on MappedByteBuffer emphasizes
"All or part of a mapped byte buffer may become inaccessible at any time",
and in the end, it mentions "Mapped byte buffers otherwise behave no
differently than ordinary direct byte buffers."

Spec doesn't mention any synchronization issues on direct byte buffers
either. Therefore, in my opnion, only synchronizing for MappedByteBuffer is
unnecessary.

Any comments? or may I miss something? Thanks!

Best regards,


-- 
Andrew Zhang
China Software Development Lab, IBM

Re: [classlib][nio] [question] Synchronization issue on MappedByteBuffer ?

Posted by "Jimmy, Jing Lv" <fi...@gmail.com>.
Andrew Zhang wrote:
> Hello everyone,
> 
> I noticed there are several FIXMEs in MappedByteBufferAdapter.java, which
> are related to synchronization issue.
> 
> Following FIXME is for getChar() method:
> 
> // FIXME Need synchronization as far as the update of this.position is
> concerned of the following methods? Spec does not say whether
> MappedByteBuffer is thread safe. It is the decision we should make.
> 
> I read through MappedByteBuffer javadoc, and didn't find any description
> about concurrent & synchronization. The spec on MappedByteBuffer emphasizes
> "All or part of a mapped byte buffer may become inaccessible at any time",
> and in the end, it mentions "Mapped byte buffers otherwise behave no
> differently than ordinary direct byte buffers."
> 

Seems few Buffer Classes apply synchronization. And according to our 
Compatibility-Guidelines, javadoc says nothing and we should follow RI, 
so maybe removing the FIXMEs is a good choice. :)
It'll be better if some test cases can be written.

> Spec doesn't mention any synchronization issues on direct byte buffers
> either. Therefore, in my opnion, only synchronizing for MappedByteBuffer is
> unnecessary.
> 
> Any comments? or may I miss something? Thanks!
> 
> Best regards,
> 
> 


-- 

Best Regards!

Jimmy, Jing Lv
China Software Development Lab, IBM

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib][nio] [question] Synchronization issue on MappedByteBuffer ?

Posted by Tim Ellison <t....@gmail.com>.
Richard Liang wrote:
> Hello Andrew,
> 
> IMHO, if the spec does not require a class thread-safe explicitly, we
> may regard the class as thread-unsafe.  Correct me if I'm wrong ;-)

I agree -- you may assume unsafe unless spec'd otherwise.

Regards,
Tim

> Andrew Zhang wrote:
>> Hello everyone,
>>
>> I noticed there are several FIXMEs in MappedByteBufferAdapter.java, which
>> are related to synchronization issue.
>>
>> Following FIXME is for getChar() method:
>>
>> // FIXME Need synchronization as far as the update of this.position is
>> concerned of the following methods? Spec does not say whether
>> MappedByteBuffer is thread safe. It is the decision we should make.
>>
>> I read through MappedByteBuffer javadoc, and didn't find any description
>> about concurrent & synchronization. The spec on MappedByteBuffer
>> emphasizes
>> "All or part of a mapped byte buffer may become inaccessible at any
>> time",
>> and in the end, it mentions "Mapped byte buffers otherwise behave no
>> differently than ordinary direct byte buffers."
>>
>> Spec doesn't mention any synchronization issues on direct byte buffers
>> either. Therefore, in my opnion, only synchronizing for
>> MappedByteBuffer is
>> unnecessary.
>>
>> Any comments? or may I miss something? Thanks!
>>
>> Best regards,
>>
>>
> 

-- 

Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org


Re: [classlib][nio] [question] Synchronization issue on MappedByteBuffer ?

Posted by Richard Liang <ri...@gmail.com>.
Hello Andrew,

IMHO, if the spec does not require a class thread-safe explicitly, we 
may regard the class as thread-unsafe.  Correct me if I'm wrong ;-) 

Andrew Zhang wrote:
> Hello everyone,
>
> I noticed there are several FIXMEs in MappedByteBufferAdapter.java, which
> are related to synchronization issue.
>
> Following FIXME is for getChar() method:
>
> // FIXME Need synchronization as far as the update of this.position is
> concerned of the following methods? Spec does not say whether
> MappedByteBuffer is thread safe. It is the decision we should make.
>
> I read through MappedByteBuffer javadoc, and didn't find any description
> about concurrent & synchronization. The spec on MappedByteBuffer 
> emphasizes
> "All or part of a mapped byte buffer may become inaccessible at any 
> time",
> and in the end, it mentions "Mapped byte buffers otherwise behave no
> differently than ordinary direct byte buffers."
>
> Spec doesn't mention any synchronization issues on direct byte buffers
> either. Therefore, in my opnion, only synchronizing for 
> MappedByteBuffer is
> unnecessary.
>
> Any comments? or may I miss something? Thanks!
>
> Best regards,
>
>

-- 
Richard Liang
China Software Development Lab, IBM 



---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
For additional commands, e-mail: harmony-dev-help@incubator.apache.org