{"id":21201696,"url":"https://github.com/oleander/the-pub-simulation","last_synced_at":"2025-11-04T11:02:19.561Z","repository":{"id":66260613,"uuid":"1343713","full_name":"oleander/The-Pub-Simulation","owner":"oleander","description":"A pub simulation in the language JR using message passing","archived":false,"fork":false,"pushed_at":"2011-08-29T07:09:16.000Z","size":6666,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-10T10:47:23.356Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/oleander/The-Pub-Simulation","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oleander.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-02-08T21:23:34.000Z","updated_at":"2022-12-10T15:38:05.000Z","dependencies_parsed_at":"2023-02-20T01:15:40.613Z","dependency_job_id":null,"html_url":"https://github.com/oleander/The-Pub-Simulation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/oleander/The-Pub-Simulation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleander%2FThe-Pub-Simulation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleander%2FThe-Pub-Simulation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleander%2FThe-Pub-Simulation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleander%2FThe-Pub-Simulation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oleander","download_url":"https://codeload.github.com/oleander/The-Pub-Simulation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oleander%2FThe-Pub-Simulation/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267361493,"owners_count":24074939,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T20:10:34.745Z","updated_at":"2025-11-04T11:02:19.462Z","avatar_url":"https://github.com/oleander.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Pub Simulation          \n\n## READ FIRST\n\nPlease consider reading this README-file at our github repo, where it is\nformatted in a more pleasent way.\n\n[Click here](https://github.com/oleander/The-Pub-Simulation) \n \n## Changes out of the ordinary\n\nWe had only some small changes.\n\n### The Door\nWe've introduced a door-class. The door is the gate into the bar.\nIt will reject customers when the bar is closed. The landlord will\nget a list of customers inside the bar by asking the door.\n\n## Solution structure\n\nWe have many classes in our solution. However, they are quite small.\nThat also makes the code much more maintainiable and very nice overall.\n\nFurthermore we are using unittesting.\n\n### Testing\n\nWe have unfortunately not tested all classes and all behaviours. We have\ntested the following:\n\n- **Door** - *We tested overall functionality, in these tests we also simultenously tested Person class*  \n- **Table** - *We tested overall functionality*  \n- **Cupboard** - *We tested thoroughly all possible ways to make ingredients by randomized testing. And therfor 'proved' that there won't be any deadlock.*  \n\nThe classes `TestPerson` and `TestAll` are pure testclasses.\n\n**Imporant Note**: We have used semaphores and synchronized at places sometimes, and if they are not used for statstics they are used for testing! \n\u003e That should be ok. \n ~~ Nicholas Smallbone, 2011\n\n## Potential deadlocks\n\nOne source of deadlock is the taking of ingredients in a bad order. Its simple to see that it never happens unless you somehow take the ingredients in different orders for the LL and BM. Furthermor we have actually tested it (see testing above).\n\nThe assistant is having it's own cycle and is always cleaning the tables, therfor the customers cant get stuck waiting to put down their glasses. And the customers wont get stuck in the queue because of that the servants don\\'t lock as stated in the paragraph above.\n\nThe Cupboard has only one inni, so it really cant get stuck without being able to listen. That means it will always appreciate putbacks of glasses and cups, therfor the Mixologists won't ever get deadlocked waiting for beverageware.\n\n## How to start the simulation\n\nSensible constants are already into `Global.jr`. So the simulation should start by simply running the main of `Simulation.jr`. The predefined values are so the closing time should be in 18 irl seconds, that is a half hour in the simulation.\n\n## Implementation\n\n*Please first look at the planing and the pictures below.*\n\nBy now you have a pretty good understanding of our intentions. However we will now dig into some details.\n\nWe only use one process for each thing, we don't share any memory except for the read-only variables in Item/Beverage/BeverageWare. One exception is that the persons write down their waiting time into a commong list which the LL later reads.\n\nBelow is a list of all classes and a short summary.\n\n### Assistant\n\nIt is very like our flow chart, only that it doesn't leave upon closal, no, it leaves when the landlord tells him too. He don't even care about calls for closing. The landlord tells the assistant to go home when only those two are left in the bar.\n\n### Barmaid\n\nNeeds no explenation, as it elegantly matches our flow chart below.\n\n### Beverage\n\nThere are totally 3 beverage **objects** in the simulation. They contain a list of ingredients and what beverageware it should served in and how long it takes to drink it.\n\n### Beverageware\n\n*extends Item*\n\nContains how much space it takes. (1 for glasses 2 for cups), there are only 2 objects of this ever created.\n\n### Clock\n\nUnchanged\n\n### Cupboard\n\nOne can aquire one item and put back one item. It will only receive aquitre-messages if it already contains that item. It contains methods to access its start and end contents, it's used by the landlord to gather statistics.\n\n### Customer\n\nWe solved the last orders problem as recommended in the assignment description. Codewise this results in that we listen to the closing time channel at two different places.\n\n### Global\n\nThis is a class with constants, references and more.\n\nGlobal contains a reference to everything static in the bar, that is everything but the customers. Also it declares constants for the all kinds of items, which are references used all over the program where appropriate.\n\nIt also contains the lists of ingredients needed to make a drink or what beverageware a drink comes in.\n\n### Item\n\nEither an ingredient or a beverageware.\n\n### Landlord\n\nThis quite similar  to our flowchart, only that the landlord tells the assistant to do his final round when everybody else have left the bar. The door kindly informs the landlord of both when two persons are left (LL + assistant) and when only LL is left.\n\nThe landlord does not put the tables and cupboard to sleep, the deadlock detection kills them.\n\n**Important Note:** We have serious problems shutdowning the clock, most likely it's a JR bug. Please see the comments in the code where we've explained the matter in more detail. The result of this is that the landlord never exits the bar as it should, but again it's probably JRs fault.\n\n### Mixologist\n\nBM and LL derives from this abstract class. It contains a method for mixing drinks.\n\n### MyTime\n\nUnchanged.\n\n### Person\n\nAbstract class that each person implements, it captures the common essence of entering/leaving the door and their loopical lifestyles.\n\n### Simulation\n\nKickstarts the simulation creating 1 customer per simulation minute.\n\n### Sleep\n\nContains one simple method for sleeping x simulation seconds.\n\n### Table\n\nThe table only takes glasses when the table have space for them.\n\n### TestAll\n\nRuns all the tests. Will only pass if it prints all tests passed. (Otherwise it might just be deadlock detection terminating the program)\n\n### TestPerson\n\nA class Door uses in the testing. This was a poor choice as it's no longer unit testing anymore.\n\n## The planing\n\nThis is what we first did before starting coding, and of course the diagrams below don't always exactly correspond to our current code, but they are pictorially describing how our code works quite accurately.\n\n### Overview\n\n![Overview](https://github.com/oleander/The-Pub-Simulation/raw/master/img/overview.jpg)\n\n### Landlord\n\n![Landlord](https://github.com/oleander/The-Pub-Simulation/raw/master/img/landlord.jpg)\n\n### Barmaid\n\n![Barmaid](https://github.com/oleander/The-Pub-Simulation/raw/master/img/barmaid.jpg)\n\n### Assistant\n\n![Assistant](https://github.com/oleander/The-Pub-Simulation/raw/master/img/assistant.jpg)\n\n### Customer\n\n![Customer](https://github.com/oleander/The-Pub-Simulation/raw/master/img/customer.jpg)\n\n### Orderdrink 1\n\n![Orderdrink 1](https://github.com/oleander/The-Pub-Simulation/raw/master/img/orderdrink1.jpg)\n\n### Orderdrink 2\n\n![Orderdrink 2](https://github.com/oleander/The-Pub-Simulation/raw/master/img/orderdrink2.jpg)\n\n### Order Drink Overview\n\n![Order Drink Overview](https://github.com/oleander/The-Pub-Simulation/raw/master/img/orderdrinkoverview.jpg)\n\n### Objects\n\n![Objects](https://github.com/oleander/The-Pub-Simulation/raw/master/img/objects.jpg)\n\n### Door\n\n![Door](https://github.com/oleander/The-Pub-Simulation/raw/master/img/door.jpg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foleander%2Fthe-pub-simulation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foleander%2Fthe-pub-simulation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foleander%2Fthe-pub-simulation/lists"}