Created
October 13, 2015 11:43
-
-
Save ilmoeuro/f5d892f1d21413cec1b2 to your computer and use it in GitHub Desktop.
process.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void init() throws InitializationException { | |
| lockActuator.init(); | |
| modemController.init(); | |
| modemController.addPhoneCallListener((phoneNumber) -> { | |
| eventQueue.offer(new PhoneCallEvent(phoneNumber)); | |
| }); | |
| } | |
| @Override | |
| @SuppressWarnings("SleepWhileInLoop") | |
| public void run() { | |
| thread.set(Thread.currentThread()); | |
| running.set(true); | |
| log.info("Lock mechanism started"); | |
| while (running.get()) { | |
| try { | |
| PhoneCallEvent event = eventQueue.take(); | |
| if (memberLookup.isAuthorizedMember(event.getPhoneNumber())) { | |
| lockActuator.setLockOpen(true); | |
| Thread.sleep(lockOpenTime); | |
| } | |
| if (Thread.interrupted()) { | |
| throw new InterruptedException(); | |
| } | |
| } catch (InterruptedException ex) { | |
| log.info("Lock mechanism interrupted"); | |
| } finally { | |
| lockActuator.setLockOpen(false); | |
| } | |
| } | |
| log.info("Lock mechanism stopped"); | |
| thread.set(null); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment