Demos update
-added functionality to detect host CPU threads count -fixed some memory leaks -now textures free memory corectly -added support for up to 32 threads
This commit is contained in:
parent
dd491302af
commit
3647fa4b86
6 changed files with 98 additions and 16 deletions
40
demos/external/sources/mmutils/thread_pool.d
vendored
40
demos/external/sources/mmutils/thread_pool.d
vendored
|
|
@ -810,6 +810,46 @@ private:
|
|||
JobData[4] resumeJobs; /// Dummu jobs to resume some thread
|
||||
|
||||
public:
|
||||
|
||||
static int getCPUCoresCount()
|
||||
{
|
||||
version(Windows)
|
||||
{
|
||||
import core.sys.windows.winbase : SYSTEM_INFO, GetSystemInfo;
|
||||
SYSTEM_INFO sysinfo;
|
||||
GetSystemInfo(&sysinfo);
|
||||
return sysinfo.dwNumberOfProcessors;
|
||||
}
|
||||
else version (linux)
|
||||
{
|
||||
version(D_BetterC)
|
||||
{
|
||||
import core.sys.posix.unistd : _SC_NPROCESSORS_ONLN, sysconf;
|
||||
return cast(int)sysconf(_SC_NPROCESSORS_ONLN);
|
||||
}
|
||||
else
|
||||
{
|
||||
import core.sys.linux.sched : CPU_COUNT, cpu_set_t, sched_getaffinity;
|
||||
import core.sys.posix.unistd : _SC_NPROCESSORS_ONLN, sysconf;
|
||||
|
||||
cpu_set_t set = void;
|
||||
if (sched_getaffinity(0, cpu_set_t.sizeof, &set) == 0)
|
||||
{
|
||||
int count = CPU_COUNT(&set);
|
||||
if (count > 0)
|
||||
return cast(uint) count;
|
||||
}
|
||||
return cast(int)sysconf(_SC_NPROCESSORS_ONLN);
|
||||
}
|
||||
}
|
||||
else version(Posix)
|
||||
{
|
||||
import core.sys.posix.unistd;
|
||||
return cast(int)sysconf(_SC_NPROCESSORS_ONLN);
|
||||
}
|
||||
else return -1;
|
||||
}
|
||||
|
||||
int jobsDoneCount()
|
||||
{
|
||||
int sum;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue