src/GlobalRoots.h
author David Anderson <dvander@alliedmods.net>
Tue Jul 24 23:53:34 2012 -0700 (2012-07-24)
changeset 86 32ad0523b309
parent 61 jitcraft/GlobalRoots.h@864e4b02a4c1
child 92 e3974e7360e9
permissions -rw-r--r--
Renamed jitcraft/ to src/, fixed some /Wp64 warnings.
     1 /*
     2  * Copyright (C) 2004-2012 David Anderson
     3  *
     4  * This file is part of SourcePawn.
     5  *
     6  * SourcePawn is free software: you can redistribute it and/or modify it under
     7  * the terms of the GNU General Public License as published by the Free
     8  * Software Foundation, either version 3 of the License, or (at your option)
     9  * any later version.
    10  * 
    11  * SourcePawn is distributed in the hope that it will be useful, but WITHOUT ANY
    12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
    14  *
    15  * You should have received a copy of the GNU General Public License along with
    16  * SourcePawn. If not, see http://www.gnu.org/licenses/.
    17  */
    18 #ifndef _include_ke_global_roots_h_
    19 #define _include_ke_global_roots_h_
    20 
    21 #include "Handles.h"
    22 #include "InlineList.h"
    23 #include "VirtualObjectVisitor.h"
    24 
    25 namespace ke {
    26 
    27 class Zone;
    28 class Object;
    29 
    30 class HeapRoot : public InlineListNode<HeapRoot>
    31 {
    32   public:
    33     Object *obj;
    34     intptr_t refcount;
    35 };
    36 
    37 class GlobalRoots
    38 {
    39     Zone *zone_;
    40 
    41   public:
    42     GlobalRoots(Zone *zone);
    43     ~GlobalRoots();
    44 
    45     bool initialize();
    46 
    47     // The caller must immediately incref this.
    48     HeapRoot *create(Handle<Object> ptr);
    49 
    50     void incref(HeapRoot *root);
    51     void decref(HeapRoot *root);
    52 
    53     void accept(VirtualObjectVisitor *visitor);
    54 
    55   private:
    56     InlineList<HeapRoot> roots_;
    57 };
    58 
    59 }
    60 
    61 #endif // _include_ke_global_roots_h_