66 }; |
66 }; |
67 static const char* to_string(kind value); |
67 static const char* to_string(kind value); |
68 }; |
68 }; |
69 private: |
69 private: |
70 // Instance state. |
70 // Instance state. |
71 const Kind::kind _kind; // For runtime type checking. |
71 Kind::kind _kind; // For runtime type checking. |
72 const uint _affinity; // Which worker should run task. |
72 uint _affinity; // Which worker should run task. |
73 GCTask* _newer; // Tasks are on doubly-linked ... |
73 GCTask* _newer; // Tasks are on doubly-linked ... |
74 GCTask* _older; // ... lists. |
74 GCTask* _older; // ... lists. |
|
75 uint _gc_id; // GC Id to use for the thread that executes this task |
75 public: |
76 public: |
76 virtual char* name() { return (char *)"task"; } |
77 virtual char* name() { return (char *)"task"; } |
|
78 |
|
79 uint gc_id() { return _gc_id; } |
77 |
80 |
78 // Abstract do_it method |
81 // Abstract do_it method |
79 virtual void do_it(GCTaskManager* manager, uint which) = 0; |
82 virtual void do_it(GCTaskManager* manager, uint which) = 0; |
80 // Accessors |
83 // Accessors |
81 Kind::kind kind() const { |
84 Kind::kind kind() const { |
114 // Constructors: Only create subclasses. |
117 // Constructors: Only create subclasses. |
115 // An ordinary GCTask. |
118 // An ordinary GCTask. |
116 GCTask(); |
119 GCTask(); |
117 // A GCTask of a particular kind, usually barrier or noop. |
120 // A GCTask of a particular kind, usually barrier or noop. |
118 GCTask(Kind::kind kind); |
121 GCTask(Kind::kind kind); |
119 // An ordinary GCTask with an affinity. |
122 GCTask(Kind::kind kind, uint gc_id); |
120 GCTask(uint affinity); |
|
121 // A GCTask of a particular kind, with and affinity. |
|
122 GCTask(Kind::kind kind, uint affinity); |
|
123 // We want a virtual destructor because virtual methods, |
123 // We want a virtual destructor because virtual methods, |
124 // but since ResourceObj's don't have their destructors |
124 // but since ResourceObj's don't have their destructors |
125 // called, we don't have one at all. Instead we have |
125 // called, we don't have one at all. Instead we have |
126 // this method, which gets called by subclasses to clean up. |
126 // this method, which gets called by subclasses to clean up. |
127 virtual void destruct(); |
127 virtual void destruct(); |
128 // Methods. |
128 // Methods. |
129 void initialize(); |
129 void initialize(Kind::kind kind, uint gc_id); |
130 }; |
130 }; |
131 |
131 |
132 // A doubly-linked list of GCTasks. |
132 // A doubly-linked list of GCTasks. |
133 // The list is not synchronized, because sometimes we want to |
133 // The list is not synchronized, because sometimes we want to |
134 // build up a list and then make it available to other threads. |
134 // build up a list and then make it available to other threads. |