Skip to content

Commit c472fb2

Browse files
committed
Improved documents
1 parent da6638b commit c472fb2

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

doc/eventdispatcher.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ EventDispatcher is something like std::map<EventType, CallbackList>.
2121

2222
EventDispatcher holds a map of `<EventType, CallbackList>` pairs. On dispatching, EventDispatcher finds the CallbackList of the event type, then invoke the callback list. The invocation is always synchronous. The listeners are triggered when `EventDispatcher::dispatch` is called.
2323

24+
All functions in EventDispatcher are also available in EventQueue.
25+
2426
<a id="a2_2"></a>
2527
## API reference
2628

@@ -101,9 +103,8 @@ If `insertListener` is called in another listener during a dispatching, the new
101103
The time complexity is O(1) plus time to look up the event in internal map.
102104

103105
Note: the caller must ensure the handle `before` is created by `this` EventDispatcher. If the caller can't ensure it, `ownsHandle` can be used
104-
to check if the handle `before` belongs to `this` EventDispatcher. The function `insert` can only be called if `ownsHandle(before)`
106+
to check if the handle `before` belongs to `this` EventDispatcher. The function `insertListener` can only be called if `ownsHandle(before)`
105107
returns true, otherwise, it's undefined behavior and it causes weird bugs.
106-
`insertListener` only `assert(ownsHandle(before))` in the underlying callback list, but there is no check in release code for performance reason.
107108

108109
#### removeListener
109110

doc/eventqueue.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ EventQueue includes all features of EventDispatcher and adds event queue feature
2020
EventQueue is asynchronous. Events are cached in the queue when `EventQueue::enqueue` is called, and dispatched later when `EventQueue::process` is called.
2121
EventQueue is equivalent to the event system (QEvent) in Qt, or the message processing in Windows API.
2222

23+
For basic functions such as add/remove listeners, please refer to the [EventDispatcher document](eventdispatcher.md).
24+
2325
<a id="a2_2"></a>
2426
## API reference
2527

0 commit comments

Comments
 (0)