| 1583 | |
| 1584 | |
| 1585 | size_t Resources::count(const Resource& that) const |
| 1586 | { |
| 1587 | foreach ( |
| 1588 | const Resource_Unsafe& resource_, |
| 1589 | resourcesNoMutationWithoutExclusiveOwnership) { |
| 1590 | if (resource_->resource == that) { |
| 1591 | // Return 1 for non-shared resources because non-shared |
| 1592 | // Resource objects in Resources are unique. |
| 1593 | return resource_->isShared() ? CHECK_NOTNONE(resource_->sharedCount) : 1; |
| 1594 | } |
| 1595 | } |
| 1596 | |
| 1597 | return 0; |
| 1598 | } |
| 1599 | |
| 1600 | |
| 1601 | void Resources::allocate(const string& role) |