本文整理汇总了C++中MemoryPool::usage_sensor方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryPool::usage_sensor方法的具体用法?C++ MemoryPool::usage_sensor怎么用?C++ MemoryPool::usage_sensor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryPool
的用法示例。
在下文中一共展示了MemoryPool::usage_sensor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: has_pending_requests
bool LowMemoryDetector::has_pending_requests() {
assert(Service_lock->owned_by_self(), "Must own Service_lock");
bool has_requests = false;
int num_memory_pools = MemoryService::num_memory_pools();
for (int i = 0; i < num_memory_pools; i++) {
MemoryPool* pool = MemoryService::get_memory_pool(i);
SensorInfo* sensor = pool->usage_sensor();
if (sensor != NULL) {
has_requests = has_requests || sensor->has_pending_requests();
}
SensorInfo* gc_sensor = pool->gc_usage_sensor();
if (gc_sensor != NULL) {
has_requests = has_requests || gc_sensor->has_pending_requests();
}
}
return has_requests;
}
示例2: process_sensor_changes
void LowMemoryDetector::process_sensor_changes(TRAPS) {
ResourceMark rm(THREAD);
HandleMark hm(THREAD);
// No need to hold Service_lock to call out to Java
int num_memory_pools = MemoryService::num_memory_pools();
for (int i = 0; i < num_memory_pools; i++) {
MemoryPool* pool = MemoryService::get_memory_pool(i);
SensorInfo* sensor = pool->usage_sensor();
SensorInfo* gc_sensor = pool->gc_usage_sensor();
if (sensor != NULL && sensor->has_pending_requests()) {
sensor->process_pending_requests(CHECK);
}
if (gc_sensor != NULL && gc_sensor->has_pending_requests()) {
gc_sensor->process_pending_requests(CHECK);
}
}
}
示例3: low_memory_detector_thread_entry
void LowMemoryDetector::low_memory_detector_thread_entry(JavaThread* jt, TRAPS) {
while (true) {
bool sensors_changed = false;
{
// _no_safepoint_check_flag is used here as LowMemory_lock is a
// special lock and the VMThread may acquire this lock at safepoint.
// Need state transition ThreadBlockInVM so that this thread
// will be handled by safepoint correctly when this thread is
// notified at a safepoint.
// This ThreadBlockInVM object is not also considered to be
// suspend-equivalent because LowMemoryDetector threads are
// not visible to external suspension.
ThreadBlockInVM tbivm(jt);
MutexLockerEx ml(LowMemory_lock, Mutex::_no_safepoint_check_flag);
while (!(sensors_changed = has_pending_requests())) {
// wait until one of the sensors has pending requests
LowMemory_lock->wait(Mutex::_no_safepoint_check_flag);
}
}
{
ResourceMark rm(THREAD);
HandleMark hm(THREAD);
// No need to hold LowMemory_lock to call out to Java
int num_memory_pools = MemoryService::num_memory_pools();
for (int i = 0; i < num_memory_pools; i++) {
MemoryPool* pool = MemoryService::get_memory_pool(i);
SensorInfo* sensor = pool->usage_sensor();
SensorInfo* gc_sensor = pool->gc_usage_sensor();
if (sensor != NULL && sensor->has_pending_requests()) {
sensor->process_pending_requests(CHECK);
}
if (gc_sensor != NULL && gc_sensor->has_pending_requests()) {
gc_sensor->process_pending_requests(CHECK);
}
}
}
}
}
示例4: detect_low_memory
// This method could be called from any Java threads
// and also VMThread.
void LowMemoryDetector::detect_low_memory() {
MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag);
bool has_pending_requests = false;
int num_memory_pools = MemoryService::num_memory_pools();
for (int i = 0; i < num_memory_pools; i++) {
MemoryPool* pool = MemoryService::get_memory_pool(i);
SensorInfo* sensor = pool->usage_sensor();
if (sensor != NULL &&
pool->usage_threshold()->is_high_threshold_supported() &&
pool->usage_threshold()->high_threshold() != 0) {
MemoryUsage usage = pool->get_memory_usage();
sensor->set_gauge_sensor_level(usage,
pool->usage_threshold());
has_pending_requests = has_pending_requests || sensor->has_pending_requests();
}
}
if (has_pending_requests) {
Service_lock->notify_all();
}
}