1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_DeferredFinalize_h 8 #define mozilla_DeferredFinalize_h 9 10 #include <cstdint> 11 12 class nsISupports; 13 14 namespace mozilla { 15 16 // Called back from DeferredFinalize. Should add 'thing' to the array of smart 17 // pointers in 'pointers', creating the array if 'pointers' is null, and return 18 // the array. 19 typedef void* (*DeferredFinalizeAppendFunction)(void* aPointers, void* aThing); 20 21 // Called to finalize a number of objects. Slice is the number of objects to 22 // finalize. The return value indicates whether it finalized all objects in the 23 // buffer. If it returns true, the function will not be called again, so the 24 // function should free aData. 25 typedef bool (*DeferredFinalizeFunction)(uint32_t aSlice, void* aData); 26 27 void DeferredFinalize(DeferredFinalizeAppendFunction aAppendFunc, 28 DeferredFinalizeFunction aFunc, void* aThing); 29 30 MOZ_NEVER_INLINE void DeferredFinalize(nsISupports* aSupports); 31 32 } // namespace mozilla 33 34 #endif // mozilla_DeferredFinalize_h 35