db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <Knut.Hat...@Sun.COM>
Subject Re: question on getChannel() synchronization in RAFContainer4.java
Date Mon, 16 Jun 2008 12:00:30 GMT
Mike Matrigali <mikem_app@sbcglobal.net> writes:

> getChannel() has comments that say callers should synchronize when
> calling.
>
> 1) why not just put the synchronization in this routine?

It is only called two places, and those two places already have a
synchronized block because of calls to getCommittedDropState(). So
synchronizing the routine wouldn't help us simplifying the code in any
of the callers.

> 2) There are 3 calls in this file that are not synchronized, is that a
> problem?  (writeAtOffset and getEmbryonicPage and
> getChannel(StorageRandomAccessFile file)

These shouldn't cause any problem because

 - getEmbryonicPage() and writeAtOffset() call
   getChannel(StorageRandomAccessFile), not getChannel(void)

 - getChannel(StorageRandomAccessFile file) calls
   RandomAccessFile.getChannel(), not RAFContainer4.getChannel().

The reason why RAFContainer4.getChannel() needs synchronization, is that
it updates a field (ourChannel). getChannel(file) only works on local
variables and therefore doesn't need synchronization.

> I have no idea if this is a problem at all, just trying to guess at a
> cause for  	 DERBY-3607

-- 
Knut Anders

Mime
View raw message