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
25 #include "precompiled.hpp"
26 #include "memory/allocation.inline.hpp"
27 #include "runtime/thread.inline.hpp"
28 #include "runtime/threadSMR.hpp"
29 #include "services/threadService.hpp"
30
31 // 'entries + 1' so we always have at least one entry.
32 ThreadsList::ThreadsList(int entries) : _length(entries), _threads(NEW_C_HEAP_ARRAY(JavaThread*, entries + 1, mtGC)), _next_list(NULL) {
33 *(JavaThread**)(_threads + entries) = NULL; // Make sure the extra entry is NULL.
34 }
35
36 ThreadsList::~ThreadsList() {
37 FREE_C_HEAP_ARRAY(JavaThread*, _threads);
38 }
39
40 ThreadsListSetter::~ThreadsListSetter() {
41 if (_target_needs_release) {
42 // The hazard ptr in the target needs to be released.
43 Threads::release_stable_list(_target);
44 }
45 }
46
47 void ThreadsListSetter::set() {
48 assert(_target->get_threads_hazard_ptr() == NULL, "hazard ptr should not already be set");
49 (void) Threads::acquire_stable_list(_target, /* is_ThreadsListSetter */ true);
50 _target_needs_release = true;
51 }
52
|
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
25 #include "precompiled.hpp"
26 #include "memory/allocation.inline.hpp"
27 #include "runtime/thread.inline.hpp"
28 #include "runtime/threadSMR.hpp"
29 #include "services/threadService.hpp"
30
31 // 'entries + 1' so we always have at least one entry.
32 ThreadsList::ThreadsList(int entries) : _length(entries), _threads(NEW_C_HEAP_ARRAY(JavaThread*, entries + 1, mtThread)), _next_list(NULL) {
33 *(JavaThread**)(_threads + entries) = NULL; // Make sure the extra entry is NULL.
34 }
35
36 ThreadsList::~ThreadsList() {
37 FREE_C_HEAP_ARRAY(JavaThread*, _threads);
38 }
39
40 ThreadsListSetter::~ThreadsListSetter() {
41 if (_target_needs_release) {
42 // The hazard ptr in the target needs to be released.
43 Threads::release_stable_list(_target);
44 }
45 }
46
47 void ThreadsListSetter::set() {
48 assert(_target->get_threads_hazard_ptr() == NULL, "hazard ptr should not already be set");
49 (void) Threads::acquire_stable_list(_target, /* is_ThreadsListSetter */ true);
50 _target_needs_release = true;
51 }
52
|