Son CV dans un terminal web en Javascript! https://terminal-cv.gregandev.fr
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

31 lines
1.5 KiB

#ifdef _WIN32
#include <windows.h>
static int initializeMemoryPriority = 1;
static MEMORY_PRIORITY_INFORMATION lowMemPriority;
static MEMORY_PRIORITY_INFORMATION normalMemPriority;
int lowerMemoryPriority(int priority) {
if (initializeMemoryPriority) {
GetThreadInformation(GetCurrentThread(), ThreadMemoryPriority, &normalMemPriority, sizeof(normalMemPriority));
// fprintf(stderr, "initialized memory %u setting to %u\n", normalMemPriority.MemoryPriority, priority);
ZeroMemory(&lowMemPriority, sizeof(lowMemPriority));
lowMemPriority.MemoryPriority = priority;
initializeMemoryPriority = 0;
}
return SetThreadInformation(GetCurrentThread(), ThreadMemoryPriority, &lowMemPriority, sizeof(lowMemPriority));
}
int setProcessMemoryPriority(int priority) {
if (initializeMemoryPriority) {
GetThreadInformation(GetCurrentThread(), ThreadMemoryPriority, &normalMemPriority, sizeof(normalMemPriority));
// fprintf(stderr, "initialized memory %u setting to %u\n", normalMemPriority.MemoryPriority, priority);
ZeroMemory(&lowMemPriority, sizeof(lowMemPriority));
lowMemPriority.MemoryPriority = priority;
initializeMemoryPriority = 0;
}
return SetProcessInformation(GetCurrentProcess(), ProcessMemoryPriority, &lowMemPriority, sizeof(lowMemPriority));
}
int restoreMemoryPriority() {
return SetThreadInformation(GetCurrentThread(), ThreadMemoryPriority, &normalMemPriority, sizeof(normalMemPriority));
}
#endif