20-CS-4003-001 Organization of Programming Languages Fall 2018
Lab Assignment 3

Lambda calculus, Type theory, Formal semantics, Program analysis

A Stream Extension

Due: 24 September, 2018 (submit instructions: here)

Lab Problem:
    Demand-driven architectures may be implemented by abstractions similar to class Stream which we developed in class. But the idea of Stream, as we discussed it, has quite a few limitations and must be extended to meet the needs of specific applications. This assignment calls for extending the Stream class in one particular way:

Create a "collector" extention of the Stream class, call it CollectorStream, which provides the following service: a CollectorStream object gets tokens from several producers and notifies a single consumer when this is accomplished. A (threaded) Notifier class will be designed and a Notifier object will be sent via a constructor argument to an object of a subclass of the CollectorStream class. The collector stream will compute a result from all producers' results, and place that result in the notifier object. A consumer thread will wait on the notifier thread until the result is received and then take the result from the notifier and print it.

Assume, to keep things simple, that the producers put "doubles" into their streams and the collector just adds those up, sets a value in the notifier, and sends it on its way.

Try this:    

Here are some classes that make use of the collector stream:
    TestCollector.java     Producer.java     Notifier.java     Stream.java     IntObject.java     Subscriber.java