src/share/vm/gc/shared/workgroup.hpp

Print this page




 364   // agree on the number of tasks.
 365   void set_n_tasks(uint t) { _n_tasks = t; }
 366 
 367   // Returns false if the next task in the sequence is unclaimed,
 368   // and ensures that it is claimed. Will set t to be the index
 369   // of the claimed task in the sequence. Will return true if
 370   // the task cannot be claimed and there are none left to claim.
 371   bool is_task_claimed(uint& t);
 372 
 373   // The calling thread asserts that it has attempted to claim
 374   // all the tasks it possibly can in the sequence. Every thread
 375   // claiming tasks must promise call this. Returns true if this
 376   // is the last thread to complete so that the thread can perform
 377   // cleanup if necessary.
 378   bool all_tasks_completed();
 379 };
 380 
 381 // Represents a set of free small integer ids.
 382 class FreeIdSet : public CHeapObj<mtInternal> {
 383   enum {
 384     end_of_list = -1,
 385     claimed = -2
 386   };
 387 
 388   int _sz;
 389   Monitor* _mon;
 390 
 391   int* _ids;
 392   int _hd;
 393   int _waiters;
 394   int _claimed;
 395 
 396   static bool _safepoint;
 397   typedef FreeIdSet* FreeIdSetPtr;
 398   static const int NSets = 10;
 399   static FreeIdSetPtr _sets[NSets];
 400   static bool _stat_init;
 401   int _index;
 402 
 403 public:
 404   FreeIdSet(int sz, Monitor* mon);
 405   ~FreeIdSet();
 406 
 407   static void set_safepoint(bool b);
 408 
 409   // Attempt to claim the given id permanently.  Returns "true" iff
 410   // successful.
 411   bool claim_perm_id(int i);
 412 
 413   // Returns an unclaimed parallel id (waiting for one to be released if
 414   // necessary).  Returns "-1" if a GC wakes up a wait for an id.
 415   int claim_par_id();
 416 
 417   void release_par_id(int id);
 418 };
 419 
 420 #endif // SHARE_VM_GC_SHARED_WORKGROUP_HPP


 364   // agree on the number of tasks.
 365   void set_n_tasks(uint t) { _n_tasks = t; }
 366 
 367   // Returns false if the next task in the sequence is unclaimed,
 368   // and ensures that it is claimed. Will set t to be the index
 369   // of the claimed task in the sequence. Will return true if
 370   // the task cannot be claimed and there are none left to claim.
 371   bool is_task_claimed(uint& t);
 372 
 373   // The calling thread asserts that it has attempted to claim
 374   // all the tasks it possibly can in the sequence. Every thread
 375   // claiming tasks must promise call this. Returns true if this
 376   // is the last thread to complete so that the thread can perform
 377   // cleanup if necessary.
 378   bool all_tasks_completed();
 379 };
 380 
 381 // Represents a set of free small integer ids.
 382 class FreeIdSet : public CHeapObj<mtInternal> {
 383   enum {
 384     end_of_list = UINT_MAX,
 385     claimed = UINT_MAX - 1
 386   };
 387 
 388   int _sz;
 389   Monitor* _mon;
 390 
 391   uint* _ids;
 392   uint _hd;
 393   uint _waiters;
 394   uint _claimed;
 395 
 396   static bool _safepoint;
 397   typedef FreeIdSet* FreeIdSetPtr;
 398   static const int NSets = 10;
 399   static FreeIdSetPtr _sets[NSets];
 400   static bool _stat_init;
 401   int _index;
 402 
 403 public:
 404   FreeIdSet(uint sz, Monitor* mon);
 405   ~FreeIdSet();
 406 
 407   static void set_safepoint(bool b);
 408 




 409   // Returns an unclaimed parallel id (waiting for one to be released if
 410   // necessary).  Returns "UINT_MAX" if a GC wakes up a wait for an id.
 411   int claim_par_id();
 412 
 413   void release_par_id(uint id);
 414 };
 415 
 416 #endif // SHARE_VM_GC_SHARED_WORKGROUP_HPP