1 /*
2 * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
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
25 //
26 // The GCTaskManager is a queue of GCTasks, and accessors
27 // to allow the queue to be accessed from many threads.
28 //
29
30 // Forward declarations of types defined in this file.
31 class GCTask;
32 class GCTaskQueue;
33 class SynchronizedGCTaskQueue;
34 class GCTaskManager;
35 class NotifyDoneClosure;
36 // Some useful subclasses of GCTask. You can also make up your own.
37 class NoopGCTask;
38 class BarrierGCTask;
39 class ReleasingBarrierGCTask;
40 class NotifyingBarrierGCTask;
41 class WaitForBarrierGCTask;
42 // A free list of Monitor*'s.
43 class MonitorSupply;
44
619 private:
620 // State.
621 // Control multi-threaded access.
622 static Mutex* _lock;
623 // The list of available Monitor*'s.
624 static GrowableArray<Monitor*>* _freelist;
625 public:
626 // Reserve a Monitor*.
627 static Monitor* reserve();
628 // Release a Monitor*.
629 static void release(Monitor* instance);
630 private:
631 // Accessors.
632 static Mutex* lock() {
633 return _lock;
634 }
635 static GrowableArray<Monitor*>* freelist() {
636 return _freelist;
637 }
638 };
|
1 /*
2 * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
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
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_GCTASKMANAGER_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_GCTASKMANAGER_HPP
27
28 #include "runtime/mutex.hpp"
29 #include "utilities/growableArray.hpp"
30
31 //
32 // The GCTaskManager is a queue of GCTasks, and accessors
33 // to allow the queue to be accessed from many threads.
34 //
35
36 // Forward declarations of types defined in this file.
37 class GCTask;
38 class GCTaskQueue;
39 class SynchronizedGCTaskQueue;
40 class GCTaskManager;
41 class NotifyDoneClosure;
42 // Some useful subclasses of GCTask. You can also make up your own.
43 class NoopGCTask;
44 class BarrierGCTask;
45 class ReleasingBarrierGCTask;
46 class NotifyingBarrierGCTask;
47 class WaitForBarrierGCTask;
48 // A free list of Monitor*'s.
49 class MonitorSupply;
50
625 private:
626 // State.
627 // Control multi-threaded access.
628 static Mutex* _lock;
629 // The list of available Monitor*'s.
630 static GrowableArray<Monitor*>* _freelist;
631 public:
632 // Reserve a Monitor*.
633 static Monitor* reserve();
634 // Release a Monitor*.
635 static void release(Monitor* instance);
636 private:
637 // Accessors.
638 static Mutex* lock() {
639 return _lock;
640 }
641 static GrowableArray<Monitor*>* freelist() {
642 return _freelist;
643 }
644 };
645
646 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_GCTASKMANAGER_HPP
|