Snippets tagged agent

  • Throttling agent

    Agent that can be used for controlling the number of concurrently executing asynchronous workflows. The agent runs a specified number of operations concurrently and queues remaining pending requests. The queued work items are started as soon as one of the previous items completes.

    21 people like this

    Posted: 13 years ago by Tomas Petricek

  • Cancellable agent

    The snippet implements a wrapper for standard F# agent that can be cancelled using the IDisposable interface. This makes it possible to use the agent locally (e.g. inside asynchronous workflow). When it is no longer needed, the agent's body is cancelled.

    11 people like this

    Posted: 13 years ago by Tomas Petricek

  • Sliding window for Observable

    Implements the Observable.windowed function that creates an observable returning a sliding window. The function is an observable version of Seq.observable. The implementation uses a simple F# agent that keeps partial windows and sends them to an observer.

    6 people like this

    Posted: 13 years ago by Tomas Petricek

  • F# counter agent

    The snippet shows a simple F# agent that calculates average from the received values. It supports one message for adding numbers to the statistics and one for resetting the state. Moreover, the agent limits the processing rate to 1 message per second.

    6 people like this

    Posted: 12 years ago by Tomas Petricek

  • Ping and Pong go Chunking Along

    Parameterizing pong allows us to do even more fun things. Here we use a few message types to allow stateful consumption of data sent by ping to its pongs.

    3 people like this

    Posted: 12 years ago by Ryan Riley

  • Reporting events from agents

    This snippet shows different options for reporting events from an F# agent. The options include triggering the event directly, using a thread pool or using a specified synchronization context.

    3 people like this

    Posted: 12 years ago by Tomas Petricek

  • Actors with control actor

    Actors with control actor. No mutable state.

    3 people like this

    Posted: 10 years ago by Tuomas Hietanen

  • Limit degree of parallelism using an agent

    The snippet implements a simple agent that limits the number of parallelism. When created, the agent takes the maximum number of tasks it can run in parallel. When it receives a "Start" message, it will then either run the task, or store it in a queue until earlier task ha completed.

    12 people like this

    Posted: 10 years ago by Tomas Petricek

  • MailboxProcessor with exception handling and restarting

    An extension of MailboxProcessor that catches all unhandled exceptions, and ensures that the user-provided function is run repeatedly until it returns normally. Based on the HandlingMailbox defined by Tomas Petricek: fssnip.net/cj

    7 people like this

    Posted: 9 years ago by Anthony Perez

  • Web Crawler

    This snippet features an F# Web crawler that i'm already using in 2 applications (slightly modified). It's based on a scalable network of communicating agents that follow URLs extracted from HTML pages until reaching the specified limit.

    8 people like this

    Posted: 3 years ago by Taha Hachana

  • Agent based ObjectPool

    This is a simple implementation of an object pool using an agent (MailboxProcessor). The pool is created with an initial number of object using the specified generator. The ObjectPool has three functions: Put: An item can be 'Put' into the pool. Get: An item can be taken from the pool ToListAndClear: A list of all the items in the pool is returned and the pool is cleared.

    9 people like this

    Posted: 13 years ago by 7sharp9

  • Agent Based Scheduler

    An agent based scheduler, can be sent a single schedule message (ScheduleOnce) and multiple schedule message (Schedule). The schedule messages comprise of a function to receive the message, the message, an initial TimeSpan before the message is scheduled, and another timespan for the schedule repeat. Check out my blog below for more details: http://bit.ly/mK4prb

    9 people like this

    Posted: 13 years ago by 7sharp9

  • Caching agent

    Agent that keeps a cache of web pages that were downloaded previously. The agent handles messages to add and get data as well as message to clear the cache.

    7 people like this

    Posted: 12 years ago by Tomas Petricek

  • Fun with Ping and Pong

    Yet another ping pong sample with agents.

    5 people like this

    Posted: 12 years ago by Ryan Riley

  • MailboxProcessor with exception handling

    An extension of MailboxProcessor that catches all unhandled exceptions (in the body of the mailbox processor) and reports them using an event. Otherwise, the public interface is the same as for MailboxProcessor.

    5 people like this

    Posted: 12 years ago by Tomas Petricek

  • Agent that can upgrade its functionality on the fly.

    Agent that can upgrade its functionality on the fly. (F# MailboxProcessor containing function in the loop...)

    5 people like this

    Posted: 11 years ago by Tuomas Hietanen

  • ManyProc

    Demonstration of the manyproc sample from Erlang using F# MailboxProcessor.

    3 people like this

    Posted: 10 years ago by Ryan Riley

  • Throttling agent

    Implements a simple agent that lets you throttle the degree of parallelism by limiting the number of work items that are processed in parallel.

    7 people like this

    Posted: 9 years ago by Tomas Petricek

  • Parallel recursive crawler using agents

    The aim here is to demonstrate a method of distributing work using the built in F# agent across multiple nodes in parallel the result of crawling one page might result in finding multiple new pages to fetch. This is a recursive process which will continue until no new URLs are found. The main focus is how to process a potentially indefinite queue of work across a pool of workers, rather than how to parse web pages.

    6 people like this

    Posted: 8 years ago by Daniel Bradley

  • Web Crawler extensions

    The snippet extends a web crawler from snippet http://fssnip.net/3K. It synchronizes all printing using an additional agent (so printed text does not interleave) and the crawling function returns an asynchronous workflow that returns when crawling completes.

    0 people like this

    Posted: 1 year ago by Tomas Petricek