ChannelWorker Module
Generic background worker that processes items sequentially from an internal queue. Fault-tolerant: errors in handlers are reported via callback without crashing the worker. Stops gracefully on cancellation.
Example
use cts = new CancellationTokenSource()
let worker = ChannelWorker.start (fun msg -> task { printfn "%s" msg }) (fun ex -> eprintfn "%A" ex) cts.Token
worker.Post("hello")
worker.Post("world")
cts.Cancel()
Types
| Type | Description |
|
Handle for a running channel worker. Post items for background processing. |
Functions and values
| Function or value |
Description
|
Full Usage:
ChannelWorker.start handler onError ct
Parameters:
'T -> Task
-
Async function to process each item.
onError : exn -> unit
-
Called when handler throws. If this also throws, the exception is swallowed.
ct : CancellationToken
-
Cancellation token to stop the worker.
Returns: Handle<'T>
|
Starts a background worker that processes items sequentially. If processing an item throws, onError is called and the worker continues. Items posted after cancellation are silently ignored. Items already queued at cancellation time may not be processed.
|
TDesu.FSharp