annotate src/share/vm/utilities/ticks.inline.hpp @ 17716:cdb71841f4bc

6498581: ThreadInterruptTest3 produces wrong output on Windows Summary: There is race condition between os::interrupt and os::is_interrupted on Windows. In JVM_Sleep(Thread.sleep), check if thread gets interrupted, it may see interrupted but not really interrupted so cause spurious waking up (early return from sleep). Fix by checking if interrupt event really gets set thus prevent false return. For intrinsic of _isInterrupted, on Windows, go fastpath only on bit not set. Reviewed-by: acorn, kvn Contributed-by: david.holmes@oracle.com, yumin.qi@oracle.com
author minqi
date Wed, 26 Feb 2014 15:20:41 -0800
parents 86e6d691f2e1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13400
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
1 /*
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
4 *
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
7 * published by the Free Software Foundation.
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
8 *
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
13 * accompanied this code).
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
14 *
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
18 *
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
21 * questions.
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
22 *
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
23 */
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
24
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
25 #ifndef SHARE_VM_UTILITIES_TICKS_INLINE_HPP
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
26 #define SHARE_VM_UTILITIES_TICKS_INLINE_HPP
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
27
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
28 #include "utilities/ticks.hpp"
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
29
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
30 inline Tickspan operator+(Tickspan lhs, const Tickspan& rhs) {
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
31 lhs += rhs;
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
32 return lhs;
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
33 }
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
34
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
35 inline bool operator==(const Tickspan& lhs, const Tickspan& rhs) {
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
36 return lhs.value() == rhs.value();
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
37 }
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
38
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
39 inline bool operator!=(const Tickspan& lhs, const Tickspan& rhs) {
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
40 return !operator==(lhs,rhs);
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
41 }
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
42
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
43 inline bool operator<(const Tickspan& lhs, const Tickspan& rhs) {
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
44 return lhs.value() < rhs.value();
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
45 }
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
46
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
47 inline bool operator>(const Tickspan& lhs, const Tickspan& rhs) {
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
48 return operator<(rhs,lhs);
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
49 }
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
50
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
51 inline bool operator<=(const Tickspan& lhs, const Tickspan& rhs) {
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
52 return !operator>(lhs,rhs);
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
53 }
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
54
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
55 inline bool operator>=(const Tickspan& lhs, const Tickspan& rhs) {
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
56 return !operator<(lhs,rhs);
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
57 }
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
58
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
59 inline Ticks operator+(Ticks lhs, const Tickspan& span) {
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
60 lhs += span;
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
61 return lhs;
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
62 }
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
63
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
64 inline Ticks operator-(Ticks lhs, const Tickspan& span) {
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
65 lhs -= span;
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
66 return lhs;
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
67 }
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
68
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
69 inline Tickspan operator-(const Ticks& end, const Ticks& start) {
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
70 return Tickspan(end, start);
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
71 }
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
72
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
73 inline bool operator==(const Ticks& lhs, const Ticks& rhs) {
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
74 return lhs.value() == rhs.value();
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
75 }
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
76
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
77 inline bool operator!=(const Ticks& lhs, const Ticks& rhs) {
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
78 return !operator==(lhs,rhs);
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
79 }
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
80
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
81 inline bool operator<(const Ticks& lhs, const Ticks& rhs) {
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
82 return lhs.value() < rhs.value();
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
83 }
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
84
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
85 inline bool operator>(const Ticks& lhs, const Ticks& rhs) {
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
86 return operator<(rhs,lhs);
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
87 }
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
88
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
89 inline bool operator<=(const Ticks& lhs, const Ticks& rhs) {
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
90 return !operator>(lhs,rhs);
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
91 }
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
92
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
93 inline bool operator>=(const Ticks& lhs, const Ticks& rhs) {
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
94 return !operator<(lhs,rhs);
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
95 }
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
96
86e6d691f2e1 8028128: Add a type safe alternative for working with counter based data
mgronlun
parents:
diff changeset
97 #endif // SHARE_VM_UTILITIES_TICKS_INLINE_HPP