Exercises

In the following exercises, you are expected to define several reactor protocols. In some cases, the task is to first investigate a specific algorithm online on your own, and then implement it using the Reactors framework. The exercises are ordered by their difficulty, and range from simple tasks to more complex ones.

  1. Define a method called twice, which takes a target channel, and returns a channel that forwards every event twice to the target.
            def twice[T](target: Channel[T]): Channel[T] 
    
  2. Define a method called throttle, which throttles the rate at which events are forwarded to the target channel.
            def throttle[T](target: Channel[T]): Channel[T] 
    

    Hint: you will have to use the Clock service and the functional event stream composition. ...

Get Learning Concurrent Programming in Scala - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.