< prev index next >

src/share/vm/gc/shared/gcId.cpp

Print this page




  36 }
  37 
  38 const uint GCId::create() {
  39   return _next_id++;
  40 }
  41 
  42 const uint GCId::peek() {
  43   return _next_id;
  44 }
  45 
  46 const uint GCId::current() {
  47   assert(currentNamedthread()->gc_id() != undefined(), "Using undefined GC id.");
  48   return current_raw();
  49 }
  50 
  51 const uint GCId::current_raw() {
  52   return currentNamedthread()->gc_id();
  53 }
  54 
  55 size_t GCId::print_prefix(char* buf, size_t len) {
  56   if (ThreadLocalStorage::is_initialized() && ThreadLocalStorage::thread()->is_Named_thread()) {

  57     uint gc_id = current_raw();
  58     if (gc_id != undefined()) {
  59       int ret = jio_snprintf(buf, len, "GC(%u) ", gc_id);
  60       assert(ret > 0, "Failed to print prefix. Log buffer too small?");
  61       return (size_t)ret;
  62     }
  63   }
  64   return 0;
  65 }
  66 
  67 GCIdMark::GCIdMark() : _gc_id(GCId::create()) {
  68   currentNamedthread()->set_gc_id(_gc_id);
  69 }
  70 
  71 GCIdMark::GCIdMark(uint gc_id) : _gc_id(gc_id) {
  72   currentNamedthread()->set_gc_id(_gc_id);
  73 }
  74 
  75 GCIdMark::~GCIdMark() {
  76   currentNamedthread()->set_gc_id(GCId::undefined());


  36 }
  37 
  38 const uint GCId::create() {
  39   return _next_id++;
  40 }
  41 
  42 const uint GCId::peek() {
  43   return _next_id;
  44 }
  45 
  46 const uint GCId::current() {
  47   assert(currentNamedthread()->gc_id() != undefined(), "Using undefined GC id.");
  48   return current_raw();
  49 }
  50 
  51 const uint GCId::current_raw() {
  52   return currentNamedthread()->gc_id();
  53 }
  54 
  55 size_t GCId::print_prefix(char* buf, size_t len) {
  56   Thread* thread = Thread::current_or_null();
  57   if (thread != NULL && thread->is_Named_thread()) {
  58     uint gc_id = current_raw();
  59     if (gc_id != undefined()) {
  60       int ret = jio_snprintf(buf, len, "GC(%u) ", gc_id);
  61       assert(ret > 0, "Failed to print prefix. Log buffer too small?");
  62       return (size_t)ret;
  63     }
  64   }
  65   return 0;
  66 }
  67 
  68 GCIdMark::GCIdMark() : _gc_id(GCId::create()) {
  69   currentNamedthread()->set_gc_id(_gc_id);
  70 }
  71 
  72 GCIdMark::GCIdMark(uint gc_id) : _gc_id(gc_id) {
  73   currentNamedthread()->set_gc_id(_gc_id);
  74 }
  75 
  76 GCIdMark::~GCIdMark() {
  77   currentNamedthread()->set_gc_id(GCId::undefined());
< prev index next >