Snippets tagged mailboxprocessor

  • Actors acting as Lambdas

    The Untyped Lambda Calculus encoded as actors (F#'s MailboxProcessors)

    2 people like this

    Posted: 6 years ago by Nick Palladinos

  • 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: 6 years ago by Tomas Petricek

  • 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

    6 people like this

    Posted: 6 years ago by 7sharp9

  • Simple timed-expiry cache

    Basic thread-safe timed-expiry cache, implemented as a MailboxProcessor.

    5 people like this

    Posted: 5 years ago by Yusuf Motara

  • 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.

    3 people like this

    Posted: 5 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.

    1 people like this

    Posted: 5 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.

    0 people like this

    Posted: 5 years ago by Tomas Petricek

  • Actors with control actor

    Actors with control actor. No mutable state.

    2 people like this

    Posted: 3 years ago by Tuomas Hietanen

  • Alternative Actor Implementation for Android

    Actor implementation (much simplified) intended for use on mobile devices. Seems to provide better memory usage behavior than native F# Mailbox Processors (MPB) (on Android). Though is not as 'smooth' as native F# MBP. Smoothness here refers to how processing is balanced between consumers and producers (most relevant to single core machines).

    8 people like this

    Posted: 3 years ago by Faisal Waris

  • Event stream projection with actors

    An example of using an actor (MailboxProcessor) to coordinate the projection of events from an event stream into a persisted projection. This example covers handling simple concurrency conflicts via also persisting and checking the latest event ID with with projection. The update command will take the current projection and apply all new events before persisting it back. The rebuild command will ignore an existing projection and replay all events in the stream.

    4 people like this

    Posted: 3 years ago by Daniel Bradley

  • Generic command/request agent with error handling

    Generic command/request agent with error handling used to serialise posted commands and requests which are defined by closures. Useful in serialising communications to an instrument with a C API.

    1 people like this

    Posted: 2 years ago by Anton Tcholakov

  • Message Passing: Ping Pong

    Message Passing sample inspired by Erlang Ping Pong from here: http://erlang.org/doc/getting_started/conc_prog.html

    3 people like this

    Posted: 1 years ago by Fabio Galuppo