< prev index next >
src/share/vm/gc/cms/yieldingWorkgroup.hpp
Print this page
*** 27,36 ****
--- 27,37 ----
#include "gc/shared/workgroup.hpp"
#include "utilities/macros.hpp"
// Forward declarations
+ class YieldingFlexibleGangTask;
class YieldingFlexibleWorkGang;
// Status of tasks
enum Status {
INACTIVE,
*** 41,57 ****
ABORTED,
COMPLETING,
COMPLETED
};
// Class YieldingFlexibleGangWorker:
// Several instances of this class run in parallel as workers for a gang.
! class YieldingFlexibleGangWorker: public GangWorker {
public:
! // Ctor
! YieldingFlexibleGangWorker(AbstractWorkGang* gang, int id) :
! GangWorker(gang, id) { }
public:
YieldingFlexibleWorkGang* yf_gang() const
{ return (YieldingFlexibleWorkGang*)gang(); }
--- 42,77 ----
ABORTED,
COMPLETING,
COMPLETED
};
+ class YieldingWorkData: public StackObj {
+ // This would be a struct, but I want accessor methods.
+ private:
+ AbstractGangTask* _task;
+ int _sequence_number;
+ public:
+ // Constructor and destructor
+ YieldingWorkData() : _task(NULL), _sequence_number(0) {}
+ ~YieldingWorkData() {}
+
+ // Accessors and modifiers
+ AbstractGangTask* task() const { return _task; }
+ void set_task(AbstractGangTask* value) { _task = value; }
+ int sequence_number() const { return _sequence_number; }
+ void set_sequence_number(int value) { _sequence_number = value; }
+
+ YieldingFlexibleGangTask* yf_task() const {
+ return (YieldingFlexibleGangTask*)_task;
+ }
+ };
+
// Class YieldingFlexibleGangWorker:
// Several instances of this class run in parallel as workers for a gang.
! class YieldingFlexibleGangWorker: public AbstractGangWorker {
public:
! YieldingFlexibleGangWorker(YieldingFlexibleWorkGang* gang, int id);
public:
YieldingFlexibleWorkGang* yf_gang() const
{ return (YieldingFlexibleWorkGang*)gang(); }
*** 158,168 ****
// Class YieldingWorkGang: A subclass of WorkGang.
// In particular, a YieldingWorkGang is made up of
// YieldingGangWorkers, and provides infrastructure
// supporting yielding to the "GangOverseer",
// being the thread that orchestrates the WorkGang via run_task().
! class YieldingFlexibleWorkGang: public FlexibleWorkGang {
// Here's the public interface to this class.
public:
// Constructor and destructor.
YieldingFlexibleWorkGang(const char* name, uint workers,
bool are_GC_task_threads);
--- 178,188 ----
// Class YieldingWorkGang: A subclass of WorkGang.
// In particular, a YieldingWorkGang is made up of
// YieldingGangWorkers, and provides infrastructure
// supporting yielding to the "GangOverseer",
// being the thread that orchestrates the WorkGang via run_task().
! class YieldingFlexibleWorkGang: public AbstractWorkGang {
// Here's the public interface to this class.
public:
// Constructor and destructor.
YieldingFlexibleWorkGang(const char* name, uint workers,
bool are_GC_task_threads);
*** 171,181 ****
assert(task() == NULL || task()->is_YieldingFlexibleGang_task(),
"Incorrect cast");
return (YieldingFlexibleGangTask*)task();
}
// Allocate a worker and return a pointer to it.
! GangWorker* allocate_worker(uint which);
// Run a task; returns when the task is done, or the workers yield,
// or the task is aborted.
// A task that has been yielded can be continued via this same interface
// by using the same task repeatedly as the argument to the call.
--- 191,201 ----
assert(task() == NULL || task()->is_YieldingFlexibleGang_task(),
"Incorrect cast");
return (YieldingFlexibleGangTask*)task();
}
// Allocate a worker and return a pointer to it.
! AbstractGangWorker* allocate_worker(uint which);
// Run a task; returns when the task is done, or the workers yield,
// or the task is aborted.
// A task that has been yielded can be continued via this same interface
// by using the same task repeatedly as the argument to the call.
*** 214,221 ****
--- 234,277 ----
}
private:
friend class YieldingFlexibleGangWorker;
void reset(); // NYI
+
+
+ // The monitor which protects these data,
+ // and notifies of changes in it.
+ Monitor* _monitor;
+ // Accessors for fields
+ Monitor* monitor() const {
+ return _monitor;
+ }
+
+ // The number of started workers.
+ uint _started_workers;
+ // The number of finished workers.
+ uint _finished_workers;
+
+ uint started_workers() const {
+ return _started_workers;
+ }
+ uint finished_workers() const {
+ return _finished_workers;
+ }
+
+ // A sequence number for the current task.
+ int _sequence_number;
+ int sequence_number() const {
+ return _sequence_number;
+ }
+
+ YieldingFlexibleGangTask* _task;
+ YieldingFlexibleGangTask* task() const {
+ return _task;
+ }
+
+ void internal_worker_poll(YieldingWorkData* data) const;
+ void internal_note_start();
+ void internal_note_finish();
};
#endif // SHARE_VM_GC_CMS_YIELDINGWORKGROUP_HPP
< prev index next >