Lines 32-38
Link Here
|
32 |
* LRU cache of buffers. The key and value for an entry |
32 |
* LRU cache of buffers. The key and value for an entry |
33 |
* in the table is the identical buffer. |
33 |
* in the table is the identical buffer. |
34 |
*/ |
34 |
*/ |
35 |
protected OverflowingLRUCache openBuffers = new BufferCache(60); |
35 |
private BufferCache openBuffers = new BufferCache(60); |
36 |
|
36 |
|
37 |
/** |
37 |
/** |
38 |
* @deprecated |
38 |
* @deprecated |
Lines 54-60
Link Here
|
54 |
String owner = ((Openable)buffer.getOwner()).toStringWithAncestors(); |
54 |
String owner = ((Openable)buffer.getOwner()).toStringWithAncestors(); |
55 |
System.out.println("Adding buffer for " + owner); //$NON-NLS-1$ |
55 |
System.out.println("Adding buffer for " + owner); //$NON-NLS-1$ |
56 |
} |
56 |
} |
57 |
this.openBuffers.put(buffer.getOwner(), buffer); |
57 |
synchronized (this.openBuffers) { |
|
|
58 |
this.openBuffers.put(buffer.getOwner(), buffer); |
59 |
} |
60 |
// close buffers that were removed from the cache if space was needed |
61 |
this.openBuffers.closeBuffers(); |
58 |
if (VERBOSE) { |
62 |
if (VERBOSE) { |
59 |
System.out.println("-> Buffer cache filling ratio = " + NumberFormat.getInstance().format(this.openBuffers.fillingRatio()) + "%"); //$NON-NLS-1$//$NON-NLS-2$ |
63 |
System.out.println("-> Buffer cache filling ratio = " + NumberFormat.getInstance().format(this.openBuffers.fillingRatio()) + "%"); //$NON-NLS-1$//$NON-NLS-2$ |
60 |
} |
64 |
} |
Lines 74-80
Link Here
|
74 |
* buffer associated with it. |
78 |
* buffer associated with it. |
75 |
*/ |
79 |
*/ |
76 |
public IBuffer getBuffer(IOpenable owner) { |
80 |
public IBuffer getBuffer(IOpenable owner) { |
77 |
return (IBuffer)this.openBuffers.get(owner); |
81 |
synchronized (this.openBuffers) { |
|
|
82 |
return (IBuffer)this.openBuffers.get(owner); |
83 |
} |
78 |
} |
84 |
} |
79 |
/** |
85 |
/** |
80 |
* Returns the default buffer manager. |
86 |
* Returns the default buffer manager. |
Lines 101-110
Link Here
|
101 |
* @return Enumeration of IBuffer |
107 |
* @return Enumeration of IBuffer |
102 |
*/ |
108 |
*/ |
103 |
public Enumeration getOpenBuffers() { |
109 |
public Enumeration getOpenBuffers() { |
|
|
110 |
Enumeration result; |
104 |
synchronized (this.openBuffers) { |
111 |
synchronized (this.openBuffers) { |
105 |
this.openBuffers.shrink(); |
112 |
this.openBuffers.shrink(); |
106 |
return this.openBuffers.elements(); |
113 |
result = this.openBuffers.elements(); |
107 |
} |
114 |
} |
|
|
115 |
// close buffers that were removed from the cache if space was needed |
116 |
this.openBuffers.closeBuffers(); |
117 |
return result; |
108 |
} |
118 |
} |
109 |
|
119 |
|
110 |
/** |
120 |
/** |
Lines 115-121
Link Here
|
115 |
String owner = ((Openable)buffer.getOwner()).toStringWithAncestors(); |
125 |
String owner = ((Openable)buffer.getOwner()).toStringWithAncestors(); |
116 |
System.out.println("Removing buffer for " + owner); //$NON-NLS-1$ |
126 |
System.out.println("Removing buffer for " + owner); //$NON-NLS-1$ |
117 |
} |
127 |
} |
118 |
this.openBuffers.remove(buffer.getOwner()); |
128 |
synchronized (this.openBuffers) { |
|
|
129 |
this.openBuffers.remove(buffer.getOwner()); |
130 |
} |
131 |
// close buffers that were removed from the cache (should be only one) |
132 |
this.openBuffers.closeBuffers(); |
119 |
if (VERBOSE) { |
133 |
if (VERBOSE) { |
120 |
System.out.println("-> Buffer cache filling ratio = " + NumberFormat.getInstance().format(this.openBuffers.fillingRatio()) + "%"); //$NON-NLS-1$//$NON-NLS-2$ |
134 |
System.out.println("-> Buffer cache filling ratio = " + NumberFormat.getInstance().format(this.openBuffers.fillingRatio()) + "%"); //$NON-NLS-1$//$NON-NLS-2$ |
121 |
} |
135 |
} |