Scheduler::unregisterResource(): act more gracefully if a resource was already unregistered
parent
b61f0b0775
commit
ce1bbbd0e0
|
@ -417,8 +417,10 @@ public:
|
||||||
*
|
*
|
||||||
* Note that the resource's won't be removed until all processes using
|
* Note that the resource's won't be removed until all processes using
|
||||||
* it have terminated)
|
* it have terminated)
|
||||||
|
*
|
||||||
|
* \return \c false if the resource could not be found
|
||||||
*/
|
*/
|
||||||
void unregisterResource(int id);
|
bool unregisterResource(int id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return the ID of a registered resource
|
* \brief Return the ID of a registered resource
|
||||||
|
|
|
@ -158,10 +158,11 @@ void Scheduler::retainResource(int id) {
|
||||||
rec->refCount++;
|
rec->refCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scheduler::unregisterResource(int id) {
|
bool Scheduler::unregisterResource(int id) {
|
||||||
LockGuard lock(m_mutex);
|
LockGuard lock(m_mutex);
|
||||||
if (m_resources.find(id) == m_resources.end()) {
|
if (m_resources.find(id) == m_resources.end()) {
|
||||||
Log(EError, "unregisterResource(): could not find the resource with ID %i!", id);
|
Log(EWarn, "unregisterResource(): could not find the resource with ID %i!", id);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
ResourceRecord *rec = m_resources[id];
|
ResourceRecord *rec = m_resources[id];
|
||||||
if (--rec->refCount == 0) {
|
if (--rec->refCount == 0) {
|
||||||
|
@ -175,6 +176,7 @@ void Scheduler::unregisterResource(int id) {
|
||||||
for (size_t i=0; i<m_workers.size(); ++i)
|
for (size_t i=0; i<m_workers.size(); ++i)
|
||||||
m_workers[i]->signalResourceExpiration(id);
|
m_workers[i]->signalResourceExpiration(id);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SerializableObject *Scheduler::getResource(int id, int coreIndex) {
|
SerializableObject *Scheduler::getResource(int id, int coreIndex) {
|
||||||
|
|
Loading…
Reference in New Issue