Skip to content

Commit 9967786

Browse files
committed
Event Based Asynchronous pattern: Add missing license header and puml diagram
1 parent 0f7b44c commit 9967786

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
@startuml
2+
package com.iluwatar.event.asynchronous {
3+
class Event {
4+
- eventId : int
5+
- eventListener : ThreadCompleteListener
6+
- eventTime : int
7+
- isComplete : boolean
8+
- isSynchronous : boolean
9+
- thread : Thread
10+
+ Event(eventId : int, eventTime : int, isSynchronous : boolean)
11+
+ addListener(listener : ThreadCompleteListener)
12+
- completed()
13+
+ isSynchronous() : boolean
14+
+ removeListener(listener : ThreadCompleteListener)
15+
+ run()
16+
+ start()
17+
+ status()
18+
+ stop()
19+
}
20+
interface ThreadCompleteListener {
21+
+ completedEventHandler(int) {abstract}
22+
}
23+
class EventManager {
24+
+ MAX_EVENT_TIME : int {static}
25+
+ MAX_ID : int {static}
26+
+ MAX_RUNNING_EVENTS : int {static}
27+
+ MIN_ID : int {static}
28+
- currentlyRunningSyncEvent : int
29+
- eventPool : Map<Integer, Event>
30+
- rand : Random
31+
+ EventManager()
32+
+ cancel(eventId : int)
33+
+ completedEventHandler(eventId : int)
34+
+ create(eventTime : int) : int
35+
+ createAsync(eventTime : int) : int
36+
- createEvent(eventTime : int, isSynchronous : boolean) : int
37+
- generateId() : int
38+
+ getEventPool() : Map<Integer, Event>
39+
+ numOfCurrentlyRunningSyncEvent() : int
40+
+ shutdown()
41+
+ start(eventId : int)
42+
+ status(eventId : int)
43+
+ statusOfAllEvents()
44+
}
45+
class App {
46+
+ PROP_FILE_NAME : String {static}
47+
~ interactiveMode : boolean
48+
+ App()
49+
+ main(args : String[]) {static}
50+
+ quickRun()
51+
+ run()
52+
+ runInteractiveMode()
53+
+ setUp()
54+
}
55+
interface IEvent {
56+
+ start() {abstract}
57+
+ status() {abstract}
58+
+ stop() {abstract}
59+
}
60+
}
61+
Event --> "-eventListener" ThreadCompleteListener
62+
EventManager --+ Map
63+
Event ..|> IEvent
64+
EventManager ..|> ThreadCompleteListener
65+
@enduml
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,24 @@
1+
#
2+
# The MIT License
3+
# Copyright (c) 2014 Ilkka Seppälä
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in
13+
# all copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
# THE SOFTWARE.
22+
#
23+
124
INTERACTIVE_MODE=NO

0 commit comments

Comments
 (0)