asynchronous - F# closures on mailbox processor threading failure -


so doing batch computation cpu intensive on books. , built tracker track computation of tasks. close on mailboxprocesser runs fine without parallelizaton when put array.parallel.map or , async workflow mailboxprocesser fails. want know why?

type timermessage =          | start of int         | tick of bool  let timer = mailboxprocessor.start(fun mbox -> let inputloop() = async {     let progress = ref 0     let amount = ref 0     let start = ref system.datetime.utcnow     while true         let! msg = mbox.receive()         match msg         | start(i) ->   amount :=                         progress := 0                         start := system.datetime.utcnow         | tick(b) -> if !amount = 0 ()                          else                             progress := !progress + 1                         let el = system.datetime.utcnow - !start                         let eta = int ((el.totalseconds/float !progress)*(float (!amount - !progress)))                         let etas = (int (eta / 3600)).tostring() + ":" + (int ((eta % 3600) / 60)).tostring() + ":" + (eta % 60).tostring()                         system.console.clear()                         system.console.write((!progress).tostring() + "/" + (!amount).tostring() + " completed [] estimated time remaining:" + etas)   } inputloop() )  let computebook (author :string) path =     let rs = readtostrings(path)     let bk = stringstobook rs     let mt = creatematrix bk 100 10 //size 100 //span 10     let res = getresults mt     //do stuff     timer.post(tick(true))     (author,path,res)   let partaopa =  //clip head clip foot no word mods     let lss = seq {for x in processtree                y in (snd x)                     yield ((fst x),y) }     let ls = seq.toarray lss //task list     timer.post(start(ls.length)) //start counter     let compls = array.map (fun l ->  computebook (fst l) (snd l) ) ls //array.parallel.map fails here same below async if put async blcoks around computbook call     //let res = compls |> async.parallel |> async.runsynchronously     writeresults compls outputfolder |> ignore     compls 


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -