6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 #include "precompiled.hpp"
25 #include "gc/z/zMetronome.hpp"
26 #include "runtime/mutexLocker.hpp"
27 #include "runtime/timer.hpp"
28 #include "utilities/ticks.hpp"
29
30 ZMetronome::ZMetronome(uint64_t hz) :
31 _monitor(Monitor::leaf, "ZMetronome", false, Monitor::_safepoint_check_never),
32 _interval_ms(MILLIUNITS / hz),
33 _start_ms(0),
34 _nticks(0),
35 _stopped(false) {}
36
37 bool ZMetronome::wait_for_tick() {
38 if (_nticks++ == 0) {
39 // First tick, set start time
40 const Ticks now = Ticks::now();
41 _start_ms = TimeHelper::counter_to_millis(now.value());
42 }
43
44 MonitorLocker ml(&_monitor, Monitor::_no_safepoint_check_flag);
45
46 while (!_stopped) {
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 #include "precompiled.hpp"
25 #include "gc/z/zMetronome.hpp"
26 #include "runtime/mutexLocker.inline.hpp"
27 #include "runtime/timer.hpp"
28 #include "utilities/ticks.hpp"
29
30 ZMetronome::ZMetronome(uint64_t hz) :
31 _monitor(Monitor::leaf, "ZMetronome", false, Monitor::_safepoint_check_never),
32 _interval_ms(MILLIUNITS / hz),
33 _start_ms(0),
34 _nticks(0),
35 _stopped(false) {}
36
37 bool ZMetronome::wait_for_tick() {
38 if (_nticks++ == 0) {
39 // First tick, set start time
40 const Ticks now = Ticks::now();
41 _start_ms = TimeHelper::counter_to_millis(now.value());
42 }
43
44 MonitorLocker ml(&_monitor, Monitor::_no_safepoint_check_flag);
45
46 while (!_stopped) {
|