Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 287096 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/wst/sse/core/internal/model/ModelManagerImpl.java (-20 / +41 lines)
Lines 108-116 Link Here
108
		int referenceCountForEdit;
108
		int referenceCountForEdit;
109
		int referenceCountForRead;
109
		int referenceCountForRead;
110
		IStructuredModel theSharedModel;
110
		IStructuredModel theSharedModel;
111
		boolean initializing = true;
111
		volatile boolean initializing = true;
112
		boolean doWait = true;
112
		volatile boolean doWait = true;
113
		
113
		final Object loadLock = new Object();
114
114
		SharedObject(IStructuredModel sharedModel) {
115
		SharedObject(IStructuredModel sharedModel) {
115
			theSharedModel = sharedModel;
116
			theSharedModel = sharedModel;
116
			referenceCountForRead = 0;
117
			referenceCountForRead = 0;
Lines 123-137 Link Here
123
		 * However, upon leaving this method, theShareModel variable
124
		 * However, upon leaving this method, theShareModel variable
124
		 * is up-to-date.
125
		 * is up-to-date.
125
		 */
126
		 */
126
		public synchronized void waitForLoadAttempt() {
127
		public void waitForLoadAttempt() {
127
			while(initializing) {
128
            int maxTimeMs = 3000;
128
				try {
129
            final int waitInterval = 1000;
129
					wait();
130
            WAIT_LOOP: while (initializing && maxTimeMs >= 0)
130
				}
131
            {
131
				catch (InterruptedException e) {
132
                try
132
					// ignore interruption!
133
                {
133
				}
134
                    synchronized(loadLock)
134
			}
135
                    {
136
                        loadLock.wait(waitInterval);
137
                    }
138
                    maxTimeMs -= waitInterval;
139
                }
140
                catch (InterruptedException e)
141
                {
142
                    break WAIT_LOOP;
143
                }
144
            }
145
146
            if (initializing)
147
            {
148
                throw new RuntimeException(
149
                        "Timed out waiting for model to load");
150
            }
135
		}
151
		}
136
		
152
		
137
		/**
153
		/**
Lines 139-147 Link Here
139
		 * {@link #waitForLoadAttempt()} will proceed after this 
155
		 * {@link #waitForLoadAttempt()} will proceed after this 
140
		 * method returns. 
156
		 * method returns. 
141
		 */
157
		 */
142
		public synchronized void setLoaded() {
158
		public void setLoaded() {
143
			initializing = false;
159
			initializing = false;
144
			notifyAll();
160
			synchronized(loadLock)
161
			{
162
			    loadLock.notifyAll();
163
			}
145
		}
164
		}
146
	}
165
	}
147
166
Lines 1159-1168 Link Here
1159
				// and return the object.
1178
				// and return the object.
1160
				SYNC.release();
1179
				SYNC.release();
1161
				doRelease=false;
1180
				doRelease=false;
1181
1182
                if (sharedObject.doWait) {
1183
                    sharedObject.waitForLoadAttempt();
1184
                }
1185
1162
				synchronized(sharedObject) {
1186
				synchronized(sharedObject) {
1163
					if (sharedObject.doWait) {
1164
						sharedObject.waitForLoadAttempt();
1165
					}
1166
					if (sharedObject.theSharedModel!=null) {
1187
					if (sharedObject.theSharedModel!=null) {
1167
						_incrCount(sharedObject, EDIT);
1188
						_incrCount(sharedObject, EDIT);
1168
					}
1189
					}
Lines 1242-1251 Link Here
1242
				SYNC.release();
1263
				SYNC.release();
1243
				doRelease=false;
1264
				doRelease=false;
1244
1265
1266
                if (sharedObject.doWait) {
1267
                    sharedObject.waitForLoadAttempt();
1268
                }
1245
				synchronized(sharedObject) {
1269
				synchronized(sharedObject) {
1246
					if (sharedObject.doWait) {
1247
						sharedObject.waitForLoadAttempt();
1248
					}
1249
					if (sharedObject.theSharedModel!=null) {
1270
					if (sharedObject.theSharedModel!=null) {
1250
						_incrCount(sharedObject, READ);
1271
						_incrCount(sharedObject, READ);
1251
					}
1272
					}

Return to bug 287096