|
||||
File indexing completed on 2025-01-18 09:57:56
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // G4AutoDelete 0027 // 0028 // Description: 0029 // 0030 // This function implements a simplified "garbage collection" mechanism 0031 // for G4-MT model. Objects are registered when created on the heap and they 0032 // will be deleted at the end of the program (like they would be if marked 0033 // as "static"). 0034 // 0035 // Limitation: 0036 // The registered object, should not contain any G4ThreadLocal data member. 0037 // Note that in general, if object is to be thread-private it is unnecessary 0038 // to mark any data-member as G4ThreadLocal. 0039 // 0040 // Performance issues: 0041 // This function uses G4ThreadLocalSingleton that on its own uses 0042 // locks and mutexes. Thus its use should be limited to only when 0043 // really necessary. 0044 // 0045 // Example: 0046 // class G4SharedByThreads 0047 // { 0048 // void calledByThreads() 0049 // { 0050 // G4Something* anObject = new G4Something; 0051 // G4AutoDelete::Register( anObject ); 0052 // } 0053 // } 0054 0055 // Author: A.Dotti (SLAC), 28 October 2013 0056 // -------------------------------------------------------------------- 0057 #ifndef G4AUTODELETE_HH 0058 #define G4AUTODELETE_HH 0059 0060 #include "G4ThreadLocalSingleton.hh" 0061 0062 namespace G4AutoDelete 0063 { 0064 template <class T> 0065 void Register(T* inst) 0066 { 0067 static G4ThreadLocalSingleton<T> container; 0068 container.Register(inst); 0069 } 0070 } // namespace G4AutoDelete 0071 0072 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |