Skip to content

Instantly share code, notes, and snippets.

@AlexCuse
Created June 6, 2011 03:33
Show Gist options
  • Save AlexCuse/1009694 to your computer and use it in GitHub Desktop.
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
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