Logo GenPRES

Agent<'T> Type

Represents an asynchronous agent that processes messages of type 'T. This is a wrapper around FSharp's MailboxProcessor, providing a unified API for agent-based concurrency.

Constructors

Constructor Description

Agent(body)

Full Usage: Agent(body)

Parameters:
Returns: Agent<'T>
body : Agent<'T> -> Async<unit>
Returns: Agent<'T>

Instance members

Instance member Description

this.CancellationToken

Full Usage: this.CancellationToken

Returns: CancellationToken

Gets the cancellation token associated with the agent.

Returns: CancellationToken

this.CurrentQueueLength

Full Usage: this.CurrentQueueLength

Returns: int

Gets the current number of messages in the agent's queue.

Returns: int

this.DefaultTimeout

Full Usage: this.DefaultTimeout

Returns: int

Gets or sets the default timeout for reply operations.

Returns: int

this.Error

Full Usage: this.Error

Returns: IEvent<Handler<Exception>, Exception>

Gets the error event for the underlying MailboxProcessor.

Returns: IEvent<Handler<Exception>, Exception>

this.IsCancellationRequested

Full Usage: this.IsCancellationRequested

Returns: bool

Gets a value indicating whether cancellation has been requested for the agent.

Returns: bool

this.OnError

Full Usage: this.OnError

Returns: IEvent<exn>

Event that is triggered when an unhandled exception occurs in the agent's processing loop.

Returns: IEvent<exn>

this.Post

Full Usage: this.Post

Parameters:
    message : 'T

Posts a message to the agent asynchronously.

message : 'T

this.PostAndAsyncReply

Full Usage: this.PostAndAsyncReply

Parameters:
Returns: Async<'a>

Posts a message to the agent and asynchronously waits for a reply.

messageBuilder : AsyncReplyChannel<'a> -> 'T
Returns: Async<'a>

this.PostAndReply

Full Usage: this.PostAndReply

Parameters:
Returns: 'Reply

Posts a message to the agent and synchronously waits for a reply.

messageBuilder : AsyncReplyChannel<'Reply> -> 'T
?timeout : int
Returns: 'Reply

this.PostAndTryAsyncReply

Full Usage: this.PostAndTryAsyncReply

Parameters:
Returns: Async<'a option>

Posts a message to the agent and asynchronously waits for a reply, with a timeout.

messageBuilder : AsyncReplyChannel<'a> -> 'T
timeout : int
Returns: Async<'a option>

this.Receive

Full Usage: this.Receive

Parameters:
    timeOut : int

Returns: Async<'T>

Receives the next message from the agent's queue asynchronously, with a timeout.

timeOut : int
Returns: Async<'T>

this.Receive

Full Usage: this.Receive

Returns: Async<'T>

Receives the next message from the agent's queue asynchronously.

Returns: Async<'T>

this.Scan

Full Usage: this.Scan

Parameters:
    scanner : 'T -> Async<'a> option

Returns: Async<'a>

Scans the agent's queue for a message matching the given scanner function.

scanner : 'T -> Async<'a> option
Returns: Async<'a>

this.Start

Full Usage: this.Start

Starts the agent's processing loop.

this.StartImmediate

Full Usage: this.StartImmediate

Starts the agent's processing loop immediately on the current thread.

this.TryPostAndReply

Full Usage: this.TryPostAndReply

Parameters:
Returns: 'a option

Posts a message to the agent and synchronously waits for a reply, with a timeout.

messageBuilder : AsyncReplyChannel<'a> -> 'T
timeout : int
Returns: 'a option

this.TryReceive

Full Usage: this.TryReceive

Parameters:
    timeout : int

Returns: Async<'T option>

Tries to receive a message from the agent's queue within the specified timeout.

timeout : int
Returns: Async<'T option>

this.TryScan

Full Usage: this.TryScan

Parameters:
    scanner : 'T -> Async<'a> option
    timeout : int

Returns: Async<'a option>

Scans the agent's queue for a message matching the given scanner function, with a timeout.

scanner : 'T -> Async<'a> option
timeout : int
Returns: Async<'a option>

Static members

Static member Description

Agent.Start(body)

Full Usage: Agent.Start(body)

Parameters:
Returns: Agent<'T>

Creates and starts a new agent with the specified body.

body : Agent<'T> -> Async<unit>
Returns: Agent<'T>

Agent.StartImmediate(body)

Full Usage: Agent.StartImmediate(body)

Parameters:
Returns: Agent<'T>

Creates and starts a new agent immediately on the current thread.

body : Agent<'T> -> Async<unit>
Returns: Agent<'T>

Type something to start searching.