YSTest: YMessage.cpp 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

YMessage.cpp
浏览该文件的文档.
1 /*
2 © 2009-2016 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #include "YSLib/Core/YModules.h"
29 #include YFM_YSLib_Core_YMessage
30
31 namespace YSLib
32 {
33
34 namespace Messaging
35 {
36
37 bool
38 operator==(const Message& x, const Message& y)
39 {
40 return x.id == y.id && x.content == y.content;
41 }
42
43 void
44 swap(Message& x, Message& y) ynothrow
45 {
46 std::swap(x.id, y.id),
47 swap(x.content, y.content);
48 }
49
50
51 void
52 MessageQueue::Merge(MessageQueue& mq)
53 {
54 std::for_each(mq.begin(), mq.end(), [this](decltype(*mq.begin()) pr){
55 if(pr.second)
56 insert(std::move(pr));
57 });
58 mq.clear();
59 }
60
61 void
62 MessageQueue::Peek(Message& msg) const
63 {
64 if(!empty())
65 msg = cbegin()->second;
66 }
67
68 void
69 MessageQueue::Pop()
70 {
71 if(!empty())
72 erase(cbegin());
73 }
74
75 void
76 MessageQueue::Push(const Message& msg, Priority prior)
77 {
78 if(msg)
79 emplace(prior, msg);
80 }
81 void
82 MessageQueue::Push(Message&& msg, Priority prior)
83 {
84 if(msg)
85 emplace(prior, std::move(msg));
86 }
87
88 void
89 MessageQueue::Remove(Priority p)
90 {
91 erase(upper_bound(p), end());
92 }
93
94
95 ImplDeDtor(MessageException)
96
97
98 ImplDeDtor(MessageSignal)
99
100 } // namespace Messaging;
101
102 } // namespace YSLib;
103
platform::msg
const string & msg
Definition: Debug.h:464
YSLib::Messaging::Priority
std::uint8_t Priority
消息优先级。
Definition: YMessage.h:51
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
YSLib::ImplDeDtor
ImplDeDtor(LoggedEvent) FatalError
Definition: YException.cpp:47
YSLib::UI::y
SPos SPos y
Definition: YWidget.cpp:44
NPL::x
const TermNode &term ynothrow const TermNode &term ynothrow const TermNode &term ynothrow TermNode &term const TermNode &term ValueNode &node const ValueNode &node const _type & x
Definition: SContext.h:94
YSLib::Messaging::operator==
bool operator==(const Message &x, const Message &y)
Definition: YMessage.cpp:38
YSLib::Messaging::MessageQueue::Push
void Push(const Message &, Priority)
若消息有效，以指定优先级插入至消息队列中。
Definition: YMessage.cpp:76
YSLib::Messaging::MessageQueue::Remove
void Remove(Priority)
移除不大于指定优先级的消息。
Definition: YMessage.cpp:89
YSLib::Messaging::MessageQueue::Peek
empty()?0 void Peek(Message &) const
合并消息队列：移动指定消息队列中的所有消息至此消息队列中。
Definition: YMessage.cpp:62
ystdex::cpp2011::end
_type * end(_type(&&array)[_vN])
Definition: range.hpp:54
YSLib::Messaging::Message
消息。
Definition: YMessage.h:65
ystdex::cpp2014::cbegin
auto cbegin(const _tRange &c) -> decltype(std::begin(c))
Definition: range.hpp:79
YSLib::Messaging::MessageQueue::Pop
void Pop()
丢弃消息队列中优先级最高的消息。
Definition: YMessage.cpp:69
YSLib::ynothrow
YB_PURE const _type size_t n ynothrow
Definition: YCoreUtilities.h:168
YSLib::Messaging::MessageSignal
消息信号：表示单一处理中断的异常。
Definition: YMessage.h:283
YSLib::Messaging::swap
void swap(Message &x, Message &y) ynothrow
Definition: YMessage.cpp:44
YModules.h
YSLib::Messaging::MessageException
消息异常。
Definition: YMessage.h:262
YSLib::Messaging::Message::id
ID id
消息标识。
Definition: YMessage.h:70
YSLib::Messaging::Message::content
ValueObject content
Definition: YMessage.h:71
CHRLib::p
const auto p(d)