Skip to content

matheusazzi/producer_consumer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ProducerConsumer

Producer's job is to generate data (a beer), put into the buffer (a fixed-size queue), and start again. At the same time, Consumers are consuming the data (removing it from the buffer), one piece at a time.

Consumers will ask for beer when they're available and Producers will be sending beers they made.

You can have multiple Producers and Consumers running, you must ensure that:

  • All Consumers drink and do it in request order;
  • Beers made first are consumed first;
  • Don't put beers into buffer if the buffer is full.

Dependencies

To run this project you must have Elixir installed on your machine.

  • Elixir 1.2 or above

Running

You can run Elixir’s interactive shell including Mix to compile the code.

iex -S mix

Then to start you need to pass a number of producers, consumers and the buffer size:

Manager.start(producers: 3, consumers: 4, buffer_size: 5)

About

Producer Consumer problem solved in Elixir

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages