 |
OpendTect
6.6
|
Go to the documentation of this file.
28 # include <tlhelp32.h>
31 # include "sys/resource.h"
47 int nicelvl =
mUdf(
int);
48 if ( !clp.
getVal(
"nice",nicelvl) )
51 setpriority( PRIO_PROCESS, pid, nicelvl );
57 setpriority( PRIO_PROCESS, pid, machprio );
65 const DWORD threadpriority =
66 machprio == 8 ? THREAD_PRIORITY_NORMAL
67 : ( machprio == 7 ? THREAD_PRIORITY_BELOW_NORMAL
68 : THREAD_PRIORITY_LOWEST );
69 if ( threadpriority != THREAD_PRIORITY_NORMAL )
70 SetPriorityClass( GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS );
72 HANDLE curthread = INVALID_HANDLE_VALUE;
73 THREADENTRY32 threadlist;
75 const DWORD dwOwnerPID( GetCurrentProcessId() );
76 curthread = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, dwOwnerPID );
77 if ( curthread == INVALID_HANDLE_VALUE )
80 threadlist.dwSize =
sizeof(THREADENTRY32);
81 if ( !Thread32First(curthread,&threadlist) )
82 { CloseHandle(curthread);
return; }
86 if ( threadlist.th32OwnerProcessID != dwOwnerPID )
89 SetThreadPriority(curthread,threadpriority );
90 }
while ( Thread32Next(curthread,&threadlist) );
92 CloseHandle( curthread );
113 BP().modulesLoaded();
121 const bool res = bp.doWork( *bp.
strm_ );
129 if ( bp.canReceiveRequests() )
134 "Batch program executor");
void doWorkCB(CallBacker *)
Definition: _execbatch.h:117
static void setBatchPriority(int argc, char **argv, float priority, int pid)
Definition: _execbatch.h:38
Locks the lock, shutting out access from other threads if needed.
Definition: threadlock.h:85
#define mSCB(fn)
Definition: callback.h:45
void Execute_batch(int *pargc, char **argv)
Definition: _execbatch.h:96
#define mIsUdf(val)
Use mIsUdf to check for undefinedness of simple types.
Definition: undefval.h:289
Main object for 'standard' batch programs.
Definition: batchprog.h:64
Threads::Lock batchprogthreadlock_
Definition: batchprog.h:134
Inherit from this class to be able to send and/or receive CallBacks.
Definition: callback.h:185
void launchDoWorkCB(CallBacker *cb)
Definition: _execbatch.h:126
void loadModulesCB(CallBacker *)
Definition: _execbatch.h:110
Definition: commandlineparser.h:53
static const char * sKeyPriority()
Definition: oscommand.h:72
od_ostream * strm_
Definition: batchprog.h:116
bool getVal(const char *key, BufferString &, bool acceptnone=false, int valnr=1) const
void loadAuto(bool late)
see class comments
Threads::Thread * thread_
Definition: batchprog.h:133
Is the base class for all threads. Start it by creating it and give it the function or CallBack to ex...
Definition: thread.h:282
#define mUdf(type)
Use this macro to get the undefined for simple types.
Definition: undefval.h:274
static int getMachinePriority(float priolevel, bool iswin)
Generated at
for the OpendTect
seismic interpretation project.
Copyright (C): dGB Beheer B.V. 1995-2021