+/**
+ * Helper to Erase an object from OwnerContainer using discard queue
+ * @param container to remove from
+ * @param object to remove
+ * @param discardQueue to put the object to
+ * @param updateBufferIndex to use
+ */
+template < class T >
+inline void EraseUsingDiscardQueue( OwnerContainer<T*>& container, T* object, DiscardQueue& discardQueue, BufferIndex updateBufferIndex )
+{
+ DALI_ASSERT_DEBUG( object && "NULL object not allowed" );
+
+ typename OwnerContainer<T*>::Iterator iter = container.Begin();
+ const typename OwnerContainer<T*>::ConstIterator endIter = container.End();
+ for ( ; iter != endIter; ++iter )
+ {
+ if ( *iter == object )
+ {
+ // Transfer ownership to the discard queue, this keeps the object alive, until the render-thread has finished with it
+ discardQueue.Add( updateBufferIndex, container.Release( iter ) );
+ return;
+ }
+ }
+}
+
+}
+
+typedef OwnerContainer< Shader* > ShaderOwner;
+typedef ShaderOwner::Iterator ShaderIter;