Advanced Modelling Features

Bin

What Is a Bin?

   
 

There is often the need for some kind of container or storages in the field of simulation. DESMO-J offers the Bin construct to model these containers.

A Bin

A Bin is characterised by its ability to store items provided by a "producer" process. These items are not distinguishable. The storage capacity of a bin is not limited.

A "consumer" process can obtain available items from the bin at any time. If there are not enough items in the bin, the requesting process is automatically inserted into an internal waiting queue until a producer delivers additional items.

This construct is exceptionally helpful in producer/consumer models, due to its internal process synchronisation abilities.

The desmoj.core.advancedModellingFeatures.Bin class (API) provides two important methods:

  • store(long n)

    The purpose of this method is to allow a "producer" to place n items in the bin.

  • retrieve(long n)

    The purpose of this method is to allow a "consumer" to remove n items from the bin. If there are not enough items available, the consumer is placed into an internal queue and automatically passivated.



   
  http://desmoj.sourceforge.net/tutorial/advanced/bin0.html