Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock Pattern #71: Added mutex and semaphore modules to demonstrate locks #397

Merged
merged 11 commits into from
Apr 18, 2016

Conversation

gwildor28
Copy link
Contributor

Added two modules to demonstrate locks.

Mutex demonstrates a simple mutual exclusion lock. This is a binary lock which only allows one thread at a time to access the resource. See: Locks on Wikipedia

Semaphore demonstrates a semaphore for controlling access to a pool of resources. See Semaphores on Wikipedia

The main class of both programs is App.java.

I haven't created any documentation yet. Let me know if you want any changes or need some explanations of the code, etc.

Added two modules to demonstrate locks.

Mutex demonstrates a simple mutual exclusion lock. Semaphore
demonstrates a semaphore for controlling access to a pool of resources.

The main class of both programs is App.java.
@gwildor28
Copy link
Contributor Author

Hi, just thought I'd check if anyone has had the opportunity to review this yet. i understand I haven't put any documentation in here yet but I just wanted to see if this is what you wanted to demonstrate the pattern

@npathai
Copy link
Contributor

npathai commented Mar 18, 2016

@gwildor28 It will be picked up for review soon.

@gwildor28
Copy link
Contributor Author

OK thanks

@iluwatar
Copy link
Owner

Review comments:

  • Mutex/App.java the pattern should be described here as well as the example implementation
  • Mutex example contains no tests
  • Mutex javadocs should be improved. They are not there just to satisfy the compiler. Please describe what each class and method does.
  • Mutex class diagram is missing
  • Mutex index.md is missing
  • Semaphore/App.java the pattern should be described here as well as the example implementation
  • Semaphore example contains no tests
  • Semaphore javadocs should be improved. They are not there just to satisfy the compiler. Please describe what each class and method does.
  • Semaphore class diagram is missing
  • Semaphore index.md is missing

*/
public class Jar {

private Lock lock;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private final Lock lock;

@iluwatar
Copy link
Owner

@gwildor28 you have my review comments. Please comment on this thread once you've addressed them so we'll do another review.

- Added descriptions
- Added junit tests
- Added javadoc
- Added index.md
- Added class diagrams
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 90.692% when pulling 6e4b269 on gwildor28:master into 35d6a54 on iluwatar:master.

@gwildor28
Copy link
Contributor Author

I've addressed the items listed in the review comments in my commit 2 days ago

@iluwatar
Copy link
Owner

@gwildor28 there are merge conflicts. Can you pull the latest changes into your fork from the master?

@gwildor28
Copy link
Contributor Author

I've merged your code into my branch, unfortunately Maven is complaining of problems in project dao. The first issue is a missing version tag in the pom.xml file, for junit-hierarchicalcontextrunner. Even after putting the tag in the file, Maven fails the tests for this project:

com.iluwatar.dao.AppTest - fails with a java.io.IOException related to the location of the database
com.iluwatar.dao.InMemoryCustomerDaoTest and com.iluwatar.dao.DbCustomerDaoTest - fail with java.lang.NoClassDefFoundError related to org/junit/internal/runners/rules/RuleFieldValidator
and de.bechte.junit.runners.validation.RuleValidator

Have you added any requirements for other software to be installed on this system?
The error in the pom.xml is the same problem that is failing the checks for this pull request

@npathai
Copy link
Contributor

npathai commented Mar 30, 2016

@gwildor28 I am the culprit for these errors. I will solve them first thing tomorrow. Sorry for the delay

@gwildor28
Copy link
Contributor Author

No problem.

@gwildor28
Copy link
Contributor Author

hi @npathai have you been able to look at this yet?

@npathai
Copy link
Contributor

npathai commented Apr 3, 2016

@gwildor28 Not yet. Give me a day, have been a bit busy.

@gwildor28
Copy link
Contributor Author

@npathai OK no problem

@gwildor28
Copy link
Contributor Author

Hi @npathai just thought to say I'm actually doing this lock pattern as part of a third year undergraduate degree module (open-source software) where I have to contribute to an existing open source project, The report is due on the 24th April and I'll get substantially more marks if I'm able to show a pull request of mine that got accepted. Do you think you'll realistically be able to sort out the errors within the next few days? Thanks

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 90.83% when pulling ca8be7c on gwildor28:master into b72214d on iluwatar:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 91.074% when pulling e821abd on gwildor28:master into b72214d on iluwatar:master.

@gwildor28
Copy link
Contributor Author

All seems to have passed the checks now, please review. Thanks

@iluwatar
Copy link
Owner

Looking quite good now @gwildor28 but still the tests are insufficient. Can you add unit test for Mutex.java and Semaphore.java?

@iluwatar iluwatar self-assigned this Apr 16, 2016
@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 91.065% when pulling a284329 on gwildor28:master into b72214d on iluwatar:master.

@gwildor28
Copy link
Contributor Author

Hi @iluwatar I've done the tests, please review. Thanks

@iluwatar iluwatar merged commit 534fb67 into iluwatar:master Apr 18, 2016
@iluwatar
Copy link
Owner

Good work @gwildor28 Great to see you pull this through! 😄

@gwildor28
Copy link
Contributor Author

Thanks

@iluwatar
Copy link
Owner

@all-contributors please add @gwildor28 for code

@allcontributors
Copy link
Contributor

@iluwatar

I've put up a pull request to add @gwildor28! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants