Created
June 6, 2011 03:33
-
-
Save AlexCuse/1009694 to your computer and use it in GitHub Desktop.
may need some stability improvements but this seems like a step in the right direction
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ObjectFactory.Initialize(fun x -> x.AddRegistry (new SearchRegistry())) | |
let write<'T> item = | |
ObjectFactory.GetAllInstances<Indexer<'T>>() | |
|> Seq.iter (fun idxr -> idxr.Index item) | |
let itemsToIndex<'T when 'T:null and 'T:not struct and 'T:equality> = | |
let p = QueueProvider<'T>.Create() | |
seq { | |
while true do | |
let obj = p.Dequeue() | |
if not (obj = null) then yield obj | |
else Thread.Sleep 1500 | |
} | |
try | |
seq { | |
yield async { itemsToIndex<Recipe> |> Seq.iter write } | |
yield async { itemsToIndex<Malt> |> Seq.iter write } | |
yield async { itemsToIndex<Hop> |> Seq.iter write } | |
yield async { itemsToIndex<Addition> |> Seq.iter write } | |
yield async { itemsToIndex<Yeast> |> Seq.iter write } | |
} | |
|> Async.Parallel | |
|> Async.RunSynchronously | |
|> ignore | |
finally | |
SearchRegistry.DeRegister() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment