| 56 | } |
| 57 | |
| 58 | int NotifyBus::CreateEvent(const std::string& name) |
| 59 | { |
| 60 | if(name.size() == 0) |
| 61 | return -1; |
| 62 | |
| 63 | LockNameMap(); |
| 64 | |
| 65 | if(name_map_.count(name)) |
| 66 | { |
| 67 | UnLockNameMap(); |
| 68 | return -1; |
| 69 | } |
| 70 | |
| 71 | int i = 0; |
| 72 | |
| 73 | for(i = 0; i < max_event_type_; i++) |
| 74 | if(event_array_[i].event < 0) |
| 75 | break; |
| 76 | |
| 77 | if(i == max_event_type_) |
| 78 | { |
| 79 | UnLockNameMap(); |
| 80 | return -1; |
| 81 | } |
| 82 | |
| 83 | /* it is safe to work on the event, since no one should touch it */ |
| 84 | |
| 85 | name_map_[name] = i; |
| 86 | event_array_[i].event = i; |
| 87 | event_array_[i].name = name; |
| 88 | ResetEventStats(&event_array_[i]); |
| 89 | |
| 90 | UnLockNameMap(); |
| 91 | |
| 92 | return i; |
| 93 | } |
| 94 | |
| 95 | int NotifyBus::GetPendingCount(EventNode* node) |
| 96 | { |