Removed Sys.setProcessPriority
This commit is contained in:
parent
f8ae518d0f
commit
89074eafa2
|
@ -50,35 +50,6 @@ public final class Sys {
|
||||||
|
|
||||||
public static final String VERSION = "0.94";
|
public static final String VERSION = "0.94";
|
||||||
|
|
||||||
/** Low process priority. @see #setProcessPriority() */
|
|
||||||
public static final int LOW_PRIORITY = -1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Normal process priority. This priority equates to the priority that the
|
|
||||||
* JVM has when it is started up normally. Note that if the JVM is started
|
|
||||||
* inside a process which is already a different priority then this will not
|
|
||||||
* be the initial priority.
|
|
||||||
*
|
|
||||||
* @see #setProcessPriority(int)
|
|
||||||
*/
|
|
||||||
public static final int NORMAL_PRIORITY = 0;
|
|
||||||
|
|
||||||
/** High process priority. @see #setProcessPriority() */
|
|
||||||
public static final int HIGH_PRIORITY = 1;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Realtime priority. Use at your own risk. This will set the java process
|
|
||||||
* priority to the highest priority the OS will normally allow. It is likely
|
|
||||||
* that this puts it at a higher priority than many OS critical tasks, such
|
|
||||||
* as disk writes or mouse input and the like. Hence it is quite possible to
|
|
||||||
* completely freeze your machine if you have an errant thread.
|
|
||||||
*
|
|
||||||
* This priority is <strong>not</strong> recommended for gaming applications.
|
|
||||||
*
|
|
||||||
* @see #setProcessPriority(int)
|
|
||||||
*/
|
|
||||||
public static final int REALTIME_PRIORITY = 2;
|
|
||||||
|
|
||||||
/** The native library name */
|
/** The native library name */
|
||||||
private static String LIBRARY_NAME = "lwjgl";
|
private static String LIBRARY_NAME = "lwjgl";
|
||||||
|
|
||||||
|
@ -166,27 +137,6 @@ public final class Sys {
|
||||||
}
|
}
|
||||||
private static native long ngetTime();
|
private static native long ngetTime();
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the process priority in a system independent way. Because of the various
|
|
||||||
* differences in operating systems this might or might not have any effect or
|
|
||||||
* the correct effect.
|
|
||||||
*
|
|
||||||
* The default process priority is NORMAL_PRIORITY.
|
|
||||||
*
|
|
||||||
* REALTIME_PRIORITY processes should theoretically be the maximum priority of
|
|
||||||
* any process on the system and may have side effects on I/O and other fundamental
|
|
||||||
* operating system functions - use with caution.
|
|
||||||
*
|
|
||||||
* It is unlikely that any games will want to change the priority of the Java
|
|
||||||
* process; but there are some other applications for this library which require
|
|
||||||
* process priority adjustments, such as in soft-realtime graphics rendering
|
|
||||||
* for broadcast television.
|
|
||||||
*
|
|
||||||
* @param priority a priority class, which will be one of REALTIME_PRIORITY,
|
|
||||||
* HIGH_PRIORITY, NORMAL_PRIORITY, or LOW_PRIORITY.
|
|
||||||
*/
|
|
||||||
public static native void setProcessPriority(int priority);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to display a modal alert to the user. This method should be used
|
* Attempt to display a modal alert to the user. This method should be used
|
||||||
* when a game fails to initialize properly or crashes out losing its display
|
* when a game fails to initialize properly or crashes out losing its display
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sched.h>
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include "org_lwjgl_Sys.h"
|
#include "org_lwjgl_Sys.h"
|
||||||
|
@ -85,59 +84,6 @@ JNIEXPORT jlong JNICALL Java_org_lwjgl_Sys_ngetTime
|
||||||
return (jlong) hires_timer;
|
return (jlong) hires_timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_lwjgl_Sys
|
|
||||||
* Method: setProcessPriority
|
|
||||||
* Signature: (I)V
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setProcessPriority
|
|
||||||
(JNIEnv * env, jclass clazz, jint priority)
|
|
||||||
{
|
|
||||||
int linux_priority;
|
|
||||||
int max_pri, min_pri;
|
|
||||||
struct sched_param sched_pri;
|
|
||||||
|
|
||||||
if (sched_getscheduler(0) != SCHED_OTHER) {
|
|
||||||
// Reset scheduler to normal
|
|
||||||
sched_pri.sched_priority = 0;
|
|
||||||
if (sched_setscheduler(0, SCHED_OTHER, &sched_pri) != 0) {
|
|
||||||
printfDebugJava(env, "Could not set realtime priority");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (priority) {
|
|
||||||
case org_lwjgl_Sys_REALTIME_PRIORITY:
|
|
||||||
min_pri = sched_get_priority_min(SCHED_FIFO);
|
|
||||||
max_pri = sched_get_priority_max(SCHED_FIFO);
|
|
||||||
if (min_pri == -1 || max_pri == -1) {
|
|
||||||
printfDebugJava(env, "Failed to set realtime priority");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sched_pri.sched_priority = (max_pri + min_pri)/2;
|
|
||||||
if (sched_setscheduler(0, SCHED_FIFO, &sched_pri) != 0) {
|
|
||||||
printfDebugJava(env, "Could not set realtime priority");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
case org_lwjgl_Sys_HIGH_PRIORITY:
|
|
||||||
linux_priority = -20;
|
|
||||||
break;
|
|
||||||
case org_lwjgl_Sys_NORMAL_PRIORITY:
|
|
||||||
linux_priority = 0;
|
|
||||||
break;
|
|
||||||
case org_lwjgl_Sys_LOW_PRIORITY:
|
|
||||||
linux_priority = 20;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (setpriority(PRIO_PROCESS, 0, linux_priority) == -1) {
|
|
||||||
printfDebugJava(env, "Failed to set priority.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_nAlert(JNIEnv * env, jclass clazz, jstring title, jstring message)
|
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_nAlert(JNIEnv * env, jclass clazz, jstring title, jstring message)
|
||||||
{
|
{
|
||||||
char * eMessageText = GetStringNativeChars(env, message);
|
char * eMessageText = GetStringNativeChars(env, message);
|
||||||
|
|
|
@ -85,11 +85,6 @@ JNIEXPORT jstring JNICALL Java_org_lwjgl_Sys_getNativeLibraryVersion(JNIEnv *env
|
||||||
return getVersionString(env);
|
return getVersionString(env);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setProcessPriority(JNIEnv * env, jclass clazz, jint priority) {
|
|
||||||
printfDebug("WARNING: setProcessPriority unsupported\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_nAlert(JNIEnv * env, jclass clazz, jstring title, jstring message)
|
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_nAlert(JNIEnv * env, jclass clazz, jstring title, jstring message)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,39 +80,6 @@ JNIEXPORT jlong JNICALL Java_org_lwjgl_Sys_ngetTime
|
||||||
return (jlong) hires_timer;
|
return (jlong) hires_timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Class: org_lwjgl_Sys
|
|
||||||
* Method: setProcessPriority
|
|
||||||
* Signature: (I)V
|
|
||||||
*/
|
|
||||||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setProcessPriority
|
|
||||||
(JNIEnv * env, jclass clazz, jint priority)
|
|
||||||
{
|
|
||||||
HANDLE me = GetCurrentProcess();
|
|
||||||
int win32priority;
|
|
||||||
|
|
||||||
switch (priority) {
|
|
||||||
case org_lwjgl_Sys_REALTIME_PRIORITY:
|
|
||||||
win32priority = REALTIME_PRIORITY_CLASS;
|
|
||||||
break;
|
|
||||||
case org_lwjgl_Sys_HIGH_PRIORITY:
|
|
||||||
win32priority = HIGH_PRIORITY_CLASS;
|
|
||||||
break;
|
|
||||||
case org_lwjgl_Sys_NORMAL_PRIORITY:
|
|
||||||
win32priority = NORMAL_PRIORITY_CLASS;
|
|
||||||
break;
|
|
||||||
case org_lwjgl_Sys_LOW_PRIORITY:
|
|
||||||
win32priority = IDLE_PRIORITY_CLASS;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!SetPriorityClass(me, win32priority)) {
|
|
||||||
printfDebug("Failed to set priority class.\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: org_lwjgl_Sys
|
* Class: org_lwjgl_Sys
|
||||||
* Method: alert
|
* Method: alert
|
||||||
|
|
Loading…
Reference in New Issue