|
From: creedon <icr...@us...> - 2005-06-13 23:22:44
|
Update of /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/Frontier In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6317 Modified Files: openDataFile Log Message: changes comments follow current stylistic practices Index: openDataFile =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/Frontier/openDataFile,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** openDataFile 26 Mar 2005 19:42:47 -0000 1.1.1.1 --- openDataFile 13 Jun 2005 23:22:33 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.Frontier.openDataFile ! on openDataFile (fname) { //returns an address ÇChanges Ç3/13/02; 7:54:42 AM by DW ÇWe used to initialize user.prefs.maxDataFiles to 5. This number is too low, and could result in thrashing on a user's machine if they have more than five data files. So we do something unusual, if the number is 5, we increase it to 25. Ç1/4/02; 2:40:13 PM by DW ÇIf the table for the file exists and has a flCompacting item, make the caller wait. Ç1/2/02; 6:11:00 PM by DW ÇCorner-turn for the Guest Databases folder in Radio ÇIf running in Frontier, no change in behavior, files still live in the Guest Databases folder. ÇIf running in Radio Ç1. Look for the file in the Data Files sub-folder of the Radio folder, if it's there, you're done. Ç2. Look for the file in the Guest Databases/ops/datafiles folder. If it's there, move it to the Data Files folder, and open that file. Ç3. If the file doesn't exist, create it in the Data Files folder. Ç5/16/01; 11:42:11 AM by DW ÇCreated. ÇWhen an application wants to open its data file, it calls this routine. If the file is already open it's fast. If it's not, we close an existing file if we're at the maximum number, then open or create the file, and return the address of a top-level table where you can store your data. This centralizes an important function. ÇThis is a higher level routine than fileMenu.openGuestDatabase, which only opens the database, it doesn't manage a pool of databases, and it doesn't do folder management. Ç5/18/01; 4:07:01 PM by DW ÇWhen opening a file, open it hidden. Ç5/19/01; 9:30:12 AM by DW ÇAdded ctAccesses to the sub-tables of datafiles. local (now = clock.now ()); local (adrfilestable = @system.temp.frontier.datafiles); bundle { //initialization if not defined (adrfilestable^) { new (tabletype, adrfilestable)}; if not defined (user.prefs.maxDataFiles) { user.prefs.maxDataFiles = 25}; if user.prefs.maxDataFiles == 5 { //see comment in changes section for 3/13/02 user.prefs.maxDataFiles = 25}}; local (adrfile = @adrfilestable^.[fname]); if defined (adrfile^) { while defined (adrfile^.flCompacting) { //1/4/02; 2:42:20 PM by DW thread.sleepTicks (30)}; if not window.isopen (adrfile^.f) { filemenu.open (adrfile^.f, true)}; adrfile^.whenLastUsed = now; adrfile^.ctAccesses++; return (adrfile^.adrData)}; if sizeof (adrfilestable^) == user.prefs.maxDataFiles { //swap out least recently used Çscratchpad.ctswaps++ semaphore.lock (this, 3600); local (adr, adrlru = nil, datelru = clock.now () + 1); for adr in adrfilestable { if adr^.whenLastUsed < datelru { adrlru = adr; datelru = adr^.whenLastUsed}}; filemenu.save (adrlru^.f); filemenu.close (adrlru^.f); delete (adrlru); semaphore.unlock (this)}; local (f, folder); bundle { //set f, folder if system.environment.isRadio { folder = frontier.pathstring + "Data Files" + file.getpathchar ()} else { folder = frontier.getsubfolder ("ops/datafiles")}; f = folder + fname + ".root"}; file.sureFilePath (f); if file.exists (f) { if not window.isopen (f) { filemenu.open (f, true)}} else { //file doesn't exist local (flnewfile = true); bundle { //if Radio, look for file in Guest Databases folder if system.environment.isRadio { local (oldfolder = frontier.getsubfolder ("ops/datafiles")); local (oldfile = oldfolder + fname + ".root"); if file.exists (oldfile) { if window.isopen (oldfile) { filemenu.save (oldfile); filemenu.close (oldfile)}; file.move (oldfile, folder); filemenu.open (f, true); flnewfile = false}}}; if flnewfile { fileMenu.new (f, hidden:true); window.setPosition (f, 30, 40); window.setSize (f, 350, 525)}}; local (adrdata = @[f].[fname]); if not defined (adrdata^) { new (tabletype, adrdata)}; new (tabletype, adrfile); adrfile^.f = f; adrfile^.whenLastUsed = now; adrfile^.adrData = adrdata; adrfile^.ctAccesses = 1; return (adrdata)}; Çbundle //test code ÇopenDataFile ("testData") \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.Frontier.openDataFile ! on openDataFile (fname) { //returns an address ÇChanges Ç3/13/02; 7:54:42 AM by DW ÇWe used to initialize user.prefs.maxDataFiles to 5. This number is too low, and could result in thrashing on a user's machine if they have more than five data files. So we do something unusual, if the number is 5, we increase it to 25. Ç1/4/02; 2:40:13 PM by DW ÇIf the table for the file exists and has a flCompacting item, make the caller wait. Ç1/2/02; 6:11:00 PM by DW ÇCorner-turn for the Guest Databases folder in Radio ÇIf running in Frontier, no change in behavior, files still live in the Guest Databases folder. ÇIf running in Radio Ç1. Look for the file in the Data Files sub-folder of the Radio folder, if it's there, you're done. Ç2. Look for the file in the Guest Databases/ops/datafiles folder. If it's there, move it to the Data Files folder, and open that file. Ç3. If the file doesn't exist, create it in the Data Files folder. Ç5/19/01; 9:30:12 AM by DW ÇAdded ctAccesses to the sub-tables of datafiles. Ç5/18/01; 4:07:01 PM by DW ÇWhen opening a file, open it hidden. Ç5/16/01; 11:42:11 AM by DW ÇCreated. ÇWhen an application wants to open its data file, it calls this routine. If the file is already open it's fast. If it's not, we close an existing file if we're at the maximum number, then open or create the file, and return the address of a top-level table where you can store your data. This centralizes an important function. ÇThis is a higher level routine than fileMenu.openGuestDatabase, which only opens the database, it doesn't manage a pool of databases, and it doesn't do folder management. local (now = clock.now ()); local (adrfilestable = @system.temp.frontier.datafiles); bundle { //initialization if not defined (adrfilestable^) { new (tabletype, adrfilestable)}; if not defined (user.prefs.maxDataFiles) { user.prefs.maxDataFiles = 25}; if user.prefs.maxDataFiles == 5 { //see comment in changes section for 3/13/02 user.prefs.maxDataFiles = 25}}; local (adrfile = @adrfilestable^.[fname]); if defined (adrfile^) { while defined (adrfile^.flCompacting) { //1/4/02; 2:42:20 PM by DW thread.sleepTicks (30)}; if not window.isopen (adrfile^.f) { filemenu.open (adrfile^.f, true)}; adrfile^.whenLastUsed = now; adrfile^.ctAccesses++; return (adrfile^.adrData)}; if sizeof (adrfilestable^) == user.prefs.maxDataFiles { //swap out least recently used Çscratchpad.ctswaps++ semaphore.lock (this, 3600); local (adr, adrlru = nil, datelru = clock.now () + 1); for adr in adrfilestable { if adr^.whenLastUsed < datelru { adrlru = adr; datelru = adr^.whenLastUsed}}; filemenu.save (adrlru^.f); filemenu.close (adrlru^.f); delete (adrlru); semaphore.unlock (this)}; local (f, folder); bundle { //set f, folder if system.environment.isRadio { folder = frontier.pathstring + "Data Files" + file.getpathchar ()} else { folder = frontier.getsubfolder ("ops/datafiles")}; f = folder + fname + ".root"}; file.sureFilePath (f); if file.exists (f) { if not window.isopen (f) { filemenu.open (f, true)}} else { //file doesn't exist local (flnewfile = true); bundle { //if Radio, look for file in Guest Databases folder if system.environment.isRadio { local (oldfolder = frontier.getsubfolder ("ops/datafiles")); local (oldfile = oldfolder + fname + ".root"); if file.exists (oldfile) { if window.isopen (oldfile) { filemenu.save (oldfile); filemenu.close (oldfile)}; file.move (oldfile, folder); filemenu.open (f, true); flnewfile = false}}}; if flnewfile { fileMenu.new (f, hidden:true); window.setPosition (f, 30, 40); window.setSize (f, 350, 525)}}; local (adrdata = @[f].[fname]); if not defined (adrdata^) { new (tabletype, adrdata)}; new (tabletype, adrfile); adrfile^.f = f; adrfile^.whenLastUsed = now; adrfile^.adrData = adrdata; adrfile^.ctAccesses = 1; return (adrdata)}; Çbundle //test code ÇopenDataFile ("testData") \ No newline at end of file |