Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [cdt-dev] DSF question

> -----Original Message-----
> From: cdt-dev-bounces@xxxxxxxxxxx 
> [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Alexiev, Dobrin
> Sent: Thursday, July 23, 2009 2:28 PM
> To: CDT General developers list.
> Subject: [cdt-dev] DSF question
> 
> Hello, 
> 
> I am starting to use DSF and here is a common usage pattern 
> I'm trying to impalement. 
> 
> Multiple clients request a single piece of data that is 
> asynchronously retrieved only once.
> When the data is finally retrieved it is made available to 
> all clients. 
> 
> I was wandering if there is a helper class I should use 
> instead of writing my own.  Is there better way to achieve this?
> 
> Here is the sketch of what I want to achieve - far from 
> elegant or synchronized. 

I've used the very same pattern in the MIVariableManager class.
I believe your idea is the way to do things.
You can look at the element MIVariableManager.operationsPending,
and you will see it is very much like yours.

Marc

 
> Thanks in advance. 
> Dobrin
> 
> Class ServiceX 
> 	Data data = null;
> 	Boolean dataRequested = false;
> 	ArrayList< DataRequestMonitor<Data >> initRMs = 
> ArrayList< 				DataRequestMonitor<Data >>();
> 
> 	Public Void SerivceX.getData( RequestMonitor rm){
> 		if( data != null) {
> 			rm.setData(data);	
> 			rm.done();
> 		}
> 		else {
> 			initRMs.add(rm); 
> 			if( !dataRequested) {
> 				dataRequested = true;
> 				requestData();
> 			}
> 		}
> 	}
> 
> 	Void requstData( Context x) {
> 		Request the calls to the backend asyncronously.
>       }
> 
> 	When the data is finally available on the backend 
> OnDone callback:
> 		data = ...;
> 		for(DataRequestMonitor rm : initRMs) {
> 			rm.setData(data);
> 			rm.done();	
> 		}
> 
> 
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
> 


Back to the top