| 277 | namespace ID { |
| 278 | |
| 279 | string generate(const string& prefix) |
| 280 | { |
| 281 | static map<string, int>* prefixes = new map<string, int>(); |
| 282 | static std::mutex* prefixes_mutex = new std::mutex(); |
| 283 | |
| 284 | int id; |
| 285 | synchronized (prefixes_mutex) { |
| 286 | int& _id = (*prefixes)[prefix]; |
| 287 | _id += 1; |
| 288 | id = _id; |
| 289 | } |
| 290 | return prefix + "(" + stringify(id) + ")"; |
| 291 | } |
| 292 | |
| 293 | } // namespace ID { |
| 294 |