test/hotspot/gtest/threadHelper.inline.hpp
author dfuchs
Fri, 06 Sep 2019 14:04:44 +0100
changeset 58031 5aaf53d4fe63
parent 54623 1126f0607c70
child 59325 3636bab5e81e
permissions -rw-r--r--
8230694: http.keepAlive system property is inconsistently/incorrectly documented Summary: trivially fixed the net-properties.html file Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
     1
/*
54416
b788c494aa46 8218483: Crash in "assert(_daemon_threads_count->get_value() > daemon_count) failed: thread count mismatch 5 : 5"
dholmes
parents: 53268
diff changeset
     2
 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
     4
 *
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
     8
 *
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    13
 * accompanied this code).
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    14
 *
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    18
 *
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    21
 * questions.
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    22
 */
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    23
51179
516acf6956a2 8207359: Make SymbolTable increment_refcount disallow zero
coleenp
parents: 50966
diff changeset
    24
#ifndef GTEST_THREADHELPER_INLINE_HPP
516acf6956a2 8207359: Make SymbolTable increment_refcount disallow zero
coleenp
parents: 50966
diff changeset
    25
#define GTEST_THREADHELPER_INLINE_HPP
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    26
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    27
#include "runtime/mutex.hpp"
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    28
#include "runtime/semaphore.hpp"
53268
c02949731190 8216560: gtest build broken on PPC64 and aarch64
mdoerr
parents: 53105
diff changeset
    29
#include "runtime/thread.inline.hpp"
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    30
#include "runtime/vmThread.hpp"
52877
9e041366c764 8214850: Rename vm_operations.?pp files to vmOperations.?pp files
tschatzl
parents: 52618
diff changeset
    31
#include "runtime/vmOperations.hpp"
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    32
#include "unittest.hpp"
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    33
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    34
class VM_StopSafepoint : public VM_Operation {
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    35
public:
52618
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
    36
  Semaphore* _running;
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    37
  Semaphore* _test_complete;
52618
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
    38
  VM_StopSafepoint(Semaphore* running, Semaphore* wait_for) :
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
    39
    _running(running), _test_complete(wait_for) {}
50966
f939a67fea30 8198720: Obsolete PrintSafepointStatistics, PrintSafepointStatisticsTimeout and PrintSafepointStatisticsCount options
coleenp
parents: 49800
diff changeset
    40
  VMOp_Type type() const          { return VMOp_None; }
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    41
  Mode evaluation_mode() const    { return _no_safepoint; }
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    42
  bool is_cheap_allocated() const { return false; }
52618
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
    43
  void doit()                     { _running->signal(); _test_complete->wait(); }
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    44
};
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    45
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    46
// This class and thread keep the non-safepoint op running while we do our testing.
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    47
class VMThreadBlocker : public JavaThread {
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    48
public:
52618
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
    49
  Semaphore _ready;
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
    50
  Semaphore _unblock;
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
    51
  VMThreadBlocker() {}
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    52
  virtual ~VMThreadBlocker() {}
53103
67e3a8b3449c 8214097: Rework thread initialization and teardown logic
dholmes
parents: 52877
diff changeset
    53
  const char* get_thread_name_string(char* buf, int buflen) const {
53105
6ac04cfbefdf 8215954: [testbug] Remove unnecessary casts in test/hotspot/gtest/threadHelper.inline.hpp
dholmes
parents: 53103
diff changeset
    54
    return "VMThreadBlocker";
53103
67e3a8b3449c 8214097: Rework thread initialization and teardown logic
dholmes
parents: 52877
diff changeset
    55
  }
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    56
  void run() {
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    57
    this->set_thread_state(_thread_in_vm);
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    58
    {
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    59
      MutexLocker ml(Threads_lock);
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    60
      Threads::add(this);
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    61
    }
52618
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
    62
    VM_StopSafepoint ss(&_ready, &_unblock);
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    63
    VMThread::execute(&ss);
53103
67e3a8b3449c 8214097: Rework thread initialization and teardown logic
dholmes
parents: 52877
diff changeset
    64
  }
67e3a8b3449c 8214097: Rework thread initialization and teardown logic
dholmes
parents: 52877
diff changeset
    65
67e3a8b3449c 8214097: Rework thread initialization and teardown logic
dholmes
parents: 52877
diff changeset
    66
  // Override as JavaThread::post_run() calls JavaThread::exit which
67e3a8b3449c 8214097: Rework thread initialization and teardown logic
dholmes
parents: 52877
diff changeset
    67
  // expects a valid thread object oop.
67e3a8b3449c 8214097: Rework thread initialization and teardown logic
dholmes
parents: 52877
diff changeset
    68
  virtual void post_run() {
54416
b788c494aa46 8218483: Crash in "assert(_daemon_threads_count->get_value() > daemon_count) failed: thread count mismatch 5 : 5"
dholmes
parents: 53268
diff changeset
    69
    Threads::remove(this, false);
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    70
    this->smr_delete();
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    71
  }
53103
67e3a8b3449c 8214097: Rework thread initialization and teardown logic
dholmes
parents: 52877
diff changeset
    72
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    73
  void doit() {
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    74
    if (os::create_thread(this, os::os_thread)) {
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    75
      os::start_thread(this);
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    76
    } else {
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    77
      ASSERT_TRUE(false);
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    78
    }
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    79
  }
52618
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
    80
  void ready() {
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
    81
    _ready.wait();
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
    82
  }
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
    83
  void release() {
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
    84
    _unblock.signal();
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
    85
  }
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    86
};
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    87
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    88
// For testing in a real JavaThread.
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    89
class JavaTestThread : public JavaThread {
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    90
public:
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    91
  Semaphore* _post;
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    92
  JavaTestThread(Semaphore* post)
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    93
    : _post(post) {
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    94
  }
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    95
  virtual ~JavaTestThread() {}
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
    96
53103
67e3a8b3449c 8214097: Rework thread initialization and teardown logic
dholmes
parents: 52877
diff changeset
    97
  const char* get_thread_name_string(char* buf, int buflen) const {
53105
6ac04cfbefdf 8215954: [testbug] Remove unnecessary casts in test/hotspot/gtest/threadHelper.inline.hpp
dholmes
parents: 53103
diff changeset
    98
    return "JavaTestThread";
53103
67e3a8b3449c 8214097: Rework thread initialization and teardown logic
dholmes
parents: 52877
diff changeset
    99
  }
67e3a8b3449c 8214097: Rework thread initialization and teardown logic
dholmes
parents: 52877
diff changeset
   100
67e3a8b3449c 8214097: Rework thread initialization and teardown logic
dholmes
parents: 52877
diff changeset
   101
  void pre_run() {
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   102
    this->set_thread_state(_thread_in_vm);
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   103
    {
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   104
      MutexLocker ml(Threads_lock);
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   105
      Threads::add(this);
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   106
    }
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   107
    {
54623
1126f0607c70 8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents: 54416
diff changeset
   108
      MutexLocker ml(SR_lock(), Mutex::_no_safepoint_check_flag);
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   109
    }
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   110
  }
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   111
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   112
  virtual void main_run() = 0;
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   113
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   114
  void run() {
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   115
    main_run();
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   116
  }
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   117
53103
67e3a8b3449c 8214097: Rework thread initialization and teardown logic
dholmes
parents: 52877
diff changeset
   118
  // Override as JavaThread::post_run() calls JavaThread::exit which
67e3a8b3449c 8214097: Rework thread initialization and teardown logic
dholmes
parents: 52877
diff changeset
   119
  // expects a valid thread object oop. And we need to call signal.
67e3a8b3449c 8214097: Rework thread initialization and teardown logic
dholmes
parents: 52877
diff changeset
   120
  void post_run() {
54416
b788c494aa46 8218483: Crash in "assert(_daemon_threads_count->get_value() > daemon_count) failed: thread count mismatch 5 : 5"
dholmes
parents: 53268
diff changeset
   121
    Threads::remove(this, false);
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   122
    _post->signal();
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   123
    this->smr_delete();
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   124
  }
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   125
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   126
  void doit() {
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   127
    if (os::create_thread(this, os::os_thread)) {
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   128
      os::start_thread(this);
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   129
    } else {
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   130
      ASSERT_TRUE(false);
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   131
    }
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   132
  }
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   133
};
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   134
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   135
template <typename FUNC>
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   136
class SingleTestThread : public JavaTestThread {
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   137
public:
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   138
  FUNC& _f;
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   139
  SingleTestThread(Semaphore* post, FUNC& f)
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   140
    : JavaTestThread(post), _f(f) {
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   141
  }
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   142
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   143
  virtual ~SingleTestThread(){}
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   144
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   145
  virtual void main_run() {
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   146
    _f(this);
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   147
  }
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   148
};
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   149
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   150
template <typename TESTFUNC>
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   151
static void nomt_test_doer(TESTFUNC &f) {
52618
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
   152
  Semaphore post;
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
   153
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
   154
  VMThreadBlocker* blocker = new VMThreadBlocker();
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   155
  blocker->doit();
52618
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
   156
  blocker->ready();
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
   157
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   158
  SingleTestThread<TESTFUNC>* stt = new SingleTestThread<TESTFUNC>(&post, f);
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   159
  stt->doit();
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   160
  post.wait();
52618
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
   161
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
   162
  blocker->release();
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   163
}
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   164
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   165
template <typename RUNNER>
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   166
static void mt_test_doer() {
52618
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
   167
  Semaphore post;
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
   168
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
   169
  VMThreadBlocker* blocker = new VMThreadBlocker();
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   170
  blocker->doit();
52618
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
   171
  blocker->ready();
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
   172
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   173
  RUNNER* runner = new RUNNER(&post);
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   174
  runner->doit();
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   175
  post.wait();
52618
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
   176
4ed308e0e89b 8213560: gtests might hang
rehn
parents: 51179
diff changeset
   177
  blocker->release();
49800
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   178
}
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   179
69d7398038c5 8195099: Concurrent safe-memory-reclamation mechanism
rehn
parents:
diff changeset
   180
#endif // include guard