diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-01-14 13:05:50 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-01-14 13:05:50 -0500 |
commit | a8b7936b17a2270e6b19cb02f25dedc33a1a076e (patch) | |
tree | 2913a0aa2bc8068cb500a456d1ae616240698508 /libdimension/raytrace.c | |
parent | 2cbebd8502fa8ca6ca65d83c55e478a3ea502627 (diff) | |
download | dimension-a8b7936b17a2270e6b19cb02f25dedc33a1a076e.tar.xz |
Make number of raytracing worker threads configurable.
Diffstat (limited to 'libdimension/raytrace.c')
-rw-r--r-- | libdimension/raytrace.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libdimension/raytrace.c b/libdimension/raytrace.c index 0e197a9..31ce24e 100644 --- a/libdimension/raytrace.c +++ b/libdimension/raytrace.c @@ -109,18 +109,20 @@ static void *dmnsn_raytrace_scene_multithread_thread(void *ptr); static int dmnsn_raytrace_scene_multithread(dmnsn_raytrace_payload *payload) { - int i, j, nthreads; + int i, j, nthreads = payload->scene->nthreads; void *ptr; int retval = 0; dmnsn_raytrace_payload *payloads; pthread_t *threads; - /* Find the number of processors/cores running (TODO: do this portably) */ - nthreads = sysconf(_SC_NPROCESSORS_ONLN); - if (nthreads < 1) { - nthreads = 1; + if (!nthreads) { + /* Find the number of processors/cores running (TODO: do this portably) */ + nthreads = sysconf(_SC_NPROCESSORS_ONLN); + if (nthreads < 1) { + nthreads = 1; + } + /* End non-portable section */ } - /* End non-portable section */ payloads = malloc(nthreads*sizeof(dmnsn_raytrace_payload)); if (!payloads) { |