add function get_sys_cpu_count()

pull/5/head
yuqing 2015-11-04 15:02:56 +08:00
parent f734884700
commit 0fe90e35da
3 changed files with 19 additions and 2 deletions

View File

@ -1,10 +1,11 @@
Version 1.23 2015-11-03
Version 1.23 2015-11-04
* sched_thread.c: task can execute in a new thread
* sched_thread.c: support delay tasks
* add function get_current_time_us and get_current_time_ms
* mblock add stat function
* add function get_sys_total_mem_size, ONLY support Linux and FreeBSD
* add function get_sys_total_mem_size and get_sys_cpu_count,
ONLY support Linux and FreeBSD
* delay task can execute in a new thread
* fast_mblock reclaimed object pool

View File

@ -2312,3 +2312,12 @@ int get_sys_total_mem_size(int64_t *mem_size)
#endif
}
int get_sys_cpu_count()
{
#if defined(OS_LINUX) || defined(OS_FREEBSD)
return sysconf(_SC_NPROCESSORS_ONLN);
#else
#error port me!
#endif
}

View File

@ -535,6 +535,13 @@ int64_t get_current_time_us();
*/
int get_sys_total_mem_size(int64_t *mem_size);
/** get system CPU count
* parameters:
* return: error no , 0 success, != 0 fail
*/
int get_sys_cpu_count();
#ifdef __cplusplus
}
#endif