| 237 | } |
| 238 | |
| 239 | bool NotifyBus::Send(int event, EventData* data, int priority) |
| 240 | { |
| 241 | EventNode* node = GetNode(event); |
| 242 | |
| 243 | if(node == nullptr) |
| 244 | return false; |
| 245 | |
| 246 | int count = GetPendingCount(node); |
| 247 | |
| 248 | if(count >= max_pending_num_) |
| 249 | { |
| 250 | node->send_fail_count++; |
| 251 | PutNode(node); |
| 252 | return false; |
| 253 | } |
| 254 | |
| 255 | node->event_tree[priority].emplace(*data); |
| 256 | |
| 257 | node->send_count++; |
| 258 | |
| 259 | if(!node->active) |
| 260 | { |
| 261 | node->active = true; |
| 262 | |
| 263 | pending_queue_mutex.lock(); |
| 264 | |
| 265 | pending_queue.push(node); |
| 266 | |
| 267 | pending_queue_mutex.unlock(); |
| 268 | } |
| 269 | |
| 270 | PutNode(node); |
| 271 | |
| 272 | return true; |
| 273 | } |
| 274 | |
| 275 | bool NotifyBus::Send(const std::string& event_name, EventData* data, int priority) |
| 276 | { |
no outgoing calls