FS#1056Dead and wrong code in RSPlatform.cpp
- Type
- Refactoring
- Status
- Closed
- Resolution
- Won't implement
- Category
- QCAD (main)
- Severity
- Very Low
- Priority
- Very Low
- Reported version
- 3.5.1
- Operating system
- All
- Reported
- 2014-05-23 by kazmer
- Closed
- 2018-10-05 by andrew
I am considering pushing the following diff:
--- a/src/core/RSPlatform.cpp
+++ b/src/core/RSPlatform.cpp
@@ -205,25 +205,6 @@ int RS::getCpuCores() {
cores = sysinfo.dwNumberOfProcessors;
#elif defined(Q_OS_UNIX)
cores = sysconf( _SC_NPROCESSORS_ONLN );
-#elif defined (Q_OS_MAC) || defined (Q_OS_BSD4) || [...]
- nt mib[4];
- size_t len;
-
- /* set the mib for hw.ncpu */
- mib[0] = CTL_HW;
- mib[1] = HW_AVAILCPU; // alternatively, try HW_NCPU;
-
- /* get the number of CPUs from the system */
- sysctl(mib, 2, &cores, &len, NULL, 0);
-
- if (cores < 1) {
- mib[1] = HW_NCPU;
- sysctl( mib, 2, &cores, &len, NULL, 0 );
- }
-#elif defined(Q_OS_HPUX)
- cores = mpctl(MPC_GETNUMSPUS, NULL, NULL);
-#elif defined(Q_OS_IRIX)
- cores = sysconf( _SC_NPROC_ONLN );
#endif
(truncated list to manage size)
I see that most of this was put in there as a kind of a note-to-self originally, however _SC_NPROCESSORS_ONLN is implemented by every realistically possible targets anyway, so for all practical purposes, this is dead weight.
A couple of questions remain, though:
- #ifdef Q_OS_WIN32 should probably be Q_OS_WIN, so as to include win64 as well.
- Assuming the real purpose for this function is to determine how many parts a particular task is to be split into in the future, if and when QCAD gets the need to split expensive tasks among multiple CPUS, "core" probably shouldn't be static - CPUs are hot-pluggable today, and while one probably doesn't do that on a laptop, it's not unfeasible in, say, a VDI environment.
Thoughts?