diff --git a/include/mitsuba/core/sched.h b/include/mitsuba/core/sched.h index b580ff2b..54e8d8dd 100644 --- a/include/mitsuba/core/sched.h +++ b/include/mitsuba/core/sched.h @@ -417,8 +417,10 @@ public: * * Note that the resource's won't be removed until all processes using * 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 diff --git a/src/libcore/sched.cpp b/src/libcore/sched.cpp index a2765adb..21f9a734 100644 --- a/src/libcore/sched.cpp +++ b/src/libcore/sched.cpp @@ -158,10 +158,11 @@ void Scheduler::retainResource(int id) { rec->refCount++; } -void Scheduler::unregisterResource(int id) { +bool Scheduler::unregisterResource(int id) { LockGuard lock(m_mutex); 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]; if (--rec->refCount == 0) { @@ -175,6 +176,7 @@ void Scheduler::unregisterResource(int id) { for (size_t i=0; isignalResourceExpiration(id); } + return true; } SerializableObject *Scheduler::getResource(int id, int coreIndex) {