digitalmars.D.learn - Thread Function does not executes
Hi All, Request your help, I have 3 functions such as below, I am calling these function using another function ptManage which executes these function's in parallel as each of the below 3 function run's on 10 - 12 different file systems, The issue is as below Issue: Most of the time the program executes perfectly, some time the function 2 is skipped, after analysis further I was able to find that if the 1st and 3rd functions(deleteFile, SizeDir) completes before the 2nd function(deleteAgedDir) then it skips, meaning the program is not waiting for all the thread to be completed before exiting the main. so any help on this would be much appreciated. Ti does not throw any exception or error the program exits' smoothly. Function: deleteFile : Delete file after a certain date deleteAgedDir : Delete folder after a certain date SizeDir : Finde Size of folder after a certain date Ex: auto deleteFile (string FFs, int AgeSize) { } auto deleteAgedDir (string FFs, int AgeSize) { } auto SizeDir (string FFs, int AgeSize) { auto TP = new TaskPool(TL); foreach (d; TP.parallel(dFiles[],1)) { Thread.sleep(5.seconds); TP.finish; } } void ptManage(T)(T function(string, string, int) coRoutine, Array!string Dirlst, int AgeSize) { alias scRType = typeof(coRoutine(string.init, string.init, int.init)); auto PFresult = taskPool.workerLocalStorage!scRType(); ReturnType!coRoutine rData; foreach (string FFs; parallel(Dirlst[0 .. $],1)) { PFresult.get ~= coRoutine(FFs.strip, Step, AgeSize); } foreach(i; PFresult.toRange) { rData ~= i[][]; } writeln(rData[]); } Void main() { ptManage(&deleteFile, CleanDirlst, AgeSize1); ptManage(&deleteAgedDi, AgedDirlst, AgeSize2); ptManage(&SizeDir, AgeSize3); } From, Vino.B
Mar 05 2018
On Monday, 5 March 2018 at 13:50:28 UTC, Vino wrote:Hi All, Request your help, I have 3 functions such as below, I am calling these function using another function ptManage which executes these function's in parallel as each of the below 3 function run's on 10 - 12 different file systems, The issue is as below Issue: Most of the time the program executes perfectly, some time the function 2 is skipped, after analysis further I was able to find that if the 1st and 3rd functions(deleteFile, SizeDir) completes before the 2nd function(deleteAgedDir) then it skips, meaning the program is not waiting for all the thread to be completed before exiting the main. so any help on this would be much appreciated. Ti does not throw any exception or error the program exits' smoothly. Function: deleteFile : Delete file after a certain date deleteAgedDir : Delete folder after a certain date SizeDir : Finde Size of folder after a certain date Ex: auto deleteFile (string FFs, int AgeSize) { } auto deleteAgedDir (string FFs, int AgeSize) { } auto SizeDir (string FFs, int AgeSize) { auto TP = new TaskPool(TL); foreach (d; TP.parallel(dFiles[],1)) { Thread.sleep(5.seconds); TP.finish; } } void ptManage(T)(T function(string, string, int) coRoutine, Array!string Dirlst, int AgeSize) { alias scRType = typeof(coRoutine(string.init, string.init, int.init)); auto PFresult = taskPool.workerLocalStorage!scRType(); ReturnType!coRoutine rData; foreach (string FFs; parallel(Dirlst[0 .. $],1)) { PFresult.get ~= coRoutine(FFs.strip, Step, AgeSize); } foreach(i; PFresult.toRange) { rData ~= i[][]; } writeln(rData[]); } Void main() { ptManage(&deleteFile, CleanDirlst, AgeSize1); ptManage(&deleteAgedDiir, AgedDirlst, AgeSize2); ptManage(&SizeDir, AgeSize3); } From, Vino.BHi All, On further analysis, as to why the function deleteAgedDir is not getting executed, found that if this function finds a folder to be deleted then it should delete the folder(rmdirRecurse(dirname)), but in this case it does not delete the folder if it finds so the return of this function is empty, if there are no file to be deleted then this function works perfectly but if there is any folder preset to be deleted this that folder is not getting deleted, so i am suspecting that the issue is with the function rmdirRecurse is not working as expected on Windows 2007, so request your help on this please. From, Vino.B
Mar 06 2018
On Tuesday, 6 March 2018 at 09:01:55 UTC, Vino wrote:On Monday, 5 March 2018 at 13:50:28 UTC, Vino wrote:Hi All, If I compile the program with 32bit(without passing -64m) then everything is working as expected. So can any one explain why the program(rmdirRecurse) does not work when compiled with 64 bit. From, Vino.B[...]Hi All, On further analysis, as to why the function deleteAgedDir is not getting executed, found that if this function finds a folder to be deleted then it should delete the folder(rmdirRecurse(dirname)), but in this case it does not delete the folder if it finds so the return of this function is empty, if there are no file to be deleted then this function works perfectly but if there is any folder preset to be deleted this that folder is not getting deleted, so i am suspecting that the issue is with the function rmdirRecurse is not working as expected on Windows 2007, so request your help on this please. From, Vino.B
Mar 08 2018