[Quantproject-developers] QuantDownloader/Downloader/OpenTickDownloader/OTManagement OTManager.cs,
Brought to you by:
glauco_1
|
From: Glauco S. <gla...@us...> - 2008-07-20 20:36:47
|
Update of /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/OTManagement In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv6919/Downloader/OpenTickDownloader/OTManagement Modified Files: OTManager.cs Log Message: Some code has been added, to avoid having too many pending requests (but it is commented out, and then non used, in this revision) Index: OTManager.cs =================================================================== RCS file: /cvsroot/quantproject/QuantDownloader/Downloader/OpenTickDownloader/OTManagement/OTManager.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** OTManager.cs 9 Jul 2008 22:21:09 -0000 1.1 --- OTManager.cs 20 Jul 2008 20:36:44 -0000 1.2 *************** *** 23,26 **** --- 23,27 ---- using System; using System.Collections; + using System.Threading; using OTFeed_NET; *************** *** 59,63 **** /// is removed /// </summary> ! private Hashtable barRequests; /// <summary> /// full path for the file where messages will be logged; if --- 60,64 ---- /// is removed /// </summary> ! private Hashtable pendingBarRequests; /// <summary> /// full path for the file where messages will be logged; if *************** *** 113,120 **** { bool wasSubmittedByThisOTManagerInstance; ! lock( this.barRequests ) { wasSubmittedByThisOTManagerInstance = ! this.barRequests.ContainsKey( requestId ); } return wasSubmittedByThisOTManagerInstance; --- 114,121 ---- { bool wasSubmittedByThisOTManagerInstance; ! lock( this.pendingBarRequests ) { wasSubmittedByThisOTManagerInstance = ! this.pendingBarRequests.ContainsKey( requestId ); } return wasSubmittedByThisOTManagerInstance; *************** *** 296,300 **** private void commonInitialization() { ! this.barRequests = new Hashtable(); this.setOTClientEventHandlers(); } --- 297,301 ---- private void commonInitialization() { ! this.pendingBarRequests = new Hashtable(); this.setOTClientEventHandlers(); } *************** *** 341,347 **** { BarRequest barRequest; ! lock ( this.barRequests ) { ! barRequest = (BarRequest)this.barRequests[ requestId ]; } if ( barRequest == null ) --- 342,348 ---- { BarRequest barRequest; ! lock ( this.pendingBarRequests ) { ! barRequest = (BarRequest)this.pendingBarRequests[ requestId ]; } if ( barRequest == null ) *************** *** 355,361 **** BarRequest barRequest = this.GetBarRequest( requestId ); ! lock ( this.barRequests ) { ! this.barRequests.Remove( requestId ); } return barRequest; --- 356,362 ---- BarRequest barRequest = this.GetBarRequest( requestId ); ! lock ( this.pendingBarRequests ) { ! this.pendingBarRequests.Remove( requestId ); } return barRequest; *************** *** 363,366 **** --- 364,380 ---- #region RequestHistData + private bool areThereTooManyPendentBarRequests() + { + bool areThereTooMany; + lock( this.pendingBarRequests ) + { + areThereTooMany = + ( this.pendingBarRequests.Count >= + DownloaderConstants.MAX_NUMBER_OF_PENDING_REQUESTS_FOR_A_SINGLE_OTMANAGER ); + } + return areThereTooMany; + } + + #region requestHistDataWithoutTooManyPendentBarRequests private int requestHistDataActually( string exchange , *************** *** 392,401 **** symbol , startingDateInUTC ); ! lock ( this.barRequests ) { ! this.barRequests.Add( requestId , barRequest ); } } ! public int RequestHistData( string exchange , string symbol , --- 406,415 ---- symbol , startingDateInUTC ); ! lock ( this.pendingBarRequests ) { ! this.pendingBarRequests.Add( requestId , barRequest ); } } ! public int requestHistDataWithoutTooManyPendentBarRequests( string exchange , string symbol , *************** *** 422,425 **** --- 436,461 ---- return requestId; } + #endregion requestHistDataWithoutTooManyPendentBarRequests + + public int RequestHistData( + string exchange , + string symbol , + DateTime startingDateInUTC , + DateTime endingDateInUTC , + OTHistoricalType oTHistoricalType , + short intervalValue ) + { + // while ( this.areThereTooManyPendentBarRequests() ) + // Thread.Sleep( 10 ); + int requestId = + this.requestHistDataWithoutTooManyPendentBarRequests( + exchange , + symbol , + startingDateInUTC , + endingDateInUTC , + oTHistoricalType , + intervalValue ); + return requestId; + } #endregion RequestHistData |