summaryrefslogtreecommitdiff
path: root/zen/process_priority.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:23:19 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:23:19 +0200
commit0887aee8c54d0ed51bb2031431e2bcdafebb4c6e (patch)
tree69537ceb9787bb25ac363cc4e6cdaf0804d78363 /zen/process_priority.h
parent5.12 (diff)
downloadFreeFileSync-0887aee8c54d0ed51bb2031431e2bcdafebb4c6e.tar.gz
FreeFileSync-0887aee8c54d0ed51bb2031431e2bcdafebb4c6e.tar.bz2
FreeFileSync-0887aee8c54d0ed51bb2031431e2bcdafebb4c6e.zip
5.13
Diffstat (limited to 'zen/process_priority.h')
-rw-r--r--zen/process_priority.h68
1 files changed, 23 insertions, 45 deletions
diff --git a/zen/process_priority.h b/zen/process_priority.h
index c0bae667..78e49cd0 100644
--- a/zen/process_priority.h
+++ b/zen/process_priority.h
@@ -1,58 +1,36 @@
+// **************************************************************************
+// * This file is part of the FreeFileSync project. It is distributed under *
+// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
+// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved *
+// **************************************************************************
#ifndef PREVENTSTANDBY_H_INCLUDED
#define PREVENTSTANDBY_H_INCLUDED
-#ifdef FFS_WIN
-#include "win.h" //includes "windows.h"
-
-#elif defined FFS_LINUX
-#endif
+#include <memory>
+#include <zen/file_error.h>
namespace zen
{
-struct PreventStandby //signal a "busy" state to the operating system
+//signal a "busy" state to the operating system
+class PreventStandby
{
-#ifdef FFS_WIN
- PreventStandby () { ::SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED /* | ES_AWAYMODE_REQUIRED*/ ); }
- ~PreventStandby() { ::SetThreadExecutionState(ES_CONTINUOUS); }
-#endif
+public:
+ PreventStandby(); //throw FileError
+ ~PreventStandby();
+private:
+ struct Pimpl;
+ std::unique_ptr<Pimpl> pimpl;
};
-
-struct ScheduleForBackgroundProcessing //lower CPU and file I/O priorities
+//lower CPU and file I/O priorities
+class ScheduleForBackgroundProcessing
{
-#ifdef FFS_WIN
-#ifndef PROCESS_MODE_BACKGROUND_BEGIN
-#define PROCESS_MODE_BACKGROUND_BEGIN 0x00100000 // Windows Server 2003 and Windows XP/2000: This value is not supported!
-#define PROCESS_MODE_BACKGROUND_END 0x00200000 //
-#endif
-
- ScheduleForBackgroundProcessing () { ::SetPriorityClass(::GetCurrentProcess(), PROCESS_MODE_BACKGROUND_BEGIN); } //this call lowers CPU priority, too!!
- ~ScheduleForBackgroundProcessing() { ::SetPriorityClass(::GetCurrentProcess(), PROCESS_MODE_BACKGROUND_END ); }
-
-#elif defined FFS_LINUX
- /*
- CPU prio:
- int getpriority(PRIO_PROCESS, 0); - errno caveat!
- int ::setpriority(PRIO_PROCESS, 0, int prio); //a zero value for "who" denotes the calling process
-
- priority can be decreased, but NOT increased :(
-
- file I/O prio:
- ScheduleForBackgroundProcessing() : oldIoPrio(::ioprio_get(IOPRIO_WHO_PROCESS, ::getpid()))
- {
- if (oldIoPrio != -1)
- ::ioprio_set(IOPRIO_WHO_PROCESS, ::getpid(), IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0));
- }
- ~ScheduleForBackgroundProcessing()
- {
- if (oldIoPrio != -1)
- ::ioprio_set(IOPRIO_WHO_PROCESS, ::getpid(), oldIoPrio);
- }
-
- private:
- const int oldIoPrio;
- */
-#endif
+public:
+ ScheduleForBackgroundProcessing(); //throw FileError
+ ~ScheduleForBackgroundProcessing();
+private:
+ struct Pimpl;
+ std::unique_ptr<Pimpl> pimpl;
};
}
bgstack15