From c76c0f017fa884c4b9a04ff7fa3b43d331c82d84 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 23 Feb 2010 14:21:48 -0500 Subject: Determine nthreads in dmnsn_new_scene(). --- libdimension/scene.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'libdimension/scene.c') diff --git a/libdimension/scene.c b/libdimension/scene.c index 8973005..8ebf706 100644 --- a/libdimension/scene.c +++ b/libdimension/scene.c @@ -20,6 +20,7 @@ #include "dimension.h" #include /* For malloc */ +#include /* For sysconf */ /* Allocate an empty scene */ dmnsn_scene * @@ -39,7 +40,12 @@ dmnsn_new_scene() scene->lights = dmnsn_new_array(sizeof(dmnsn_light *)); scene->quality = DMNSN_RENDER_FULL; scene->reclimit = 5; - scene->nthreads = 0; + + /* Find the number of processors/cores running (TODO: do this portably) */ + int nprocs = sysconf(_SC_NPROCESSORS_ONLN); + if (nprocs < 1) + nprocs = 1; + scene->nthreads = nprocs; } return scene; } -- cgit v1.2.3