What I am going after is to isolate the pure algorithm as one function, from everything else like input validation and what not. Because later the algorithms will get bigger and checking all the alpha and region cases in different loops will lead to messy code. For now I will leave that as it is, but I think if I create such function that would validate input and modify the images as needed, we will have much simpler code. But ok, let's leave that for now, you guys will see some code soon and have a better look at the situation.
About the parallel_image function in src/maketx/maketx.cpp. I am using it as example to make a function for Over. 1. I am thinking about having a return type bool instead of void. Imagine if you called parallel_image with nthreads = 100 and for some reason it did not succeed in creating 100 threads. Reason being wrong version of boost or else. If I want to do my operation on 100 processors and for some reason it still was done on 1, I would like to know about that :). We could return false in such cases where number of threads was specified but still that many threads can't be created. 2. If you agree parallel_image to return bool, how to handle this case: R.spec().image_pixels() < 1000 && nthreads > 1, which means that there are not enough pixels in the image to parallelize the operation and number of threads is specified. Should we fail because we specified nthreads for example to be 5 and yet because of not enough pixels it still will be done on 1 thread? 3. Possible general rules: If for whatever reason we can't create as many threads as specified by the parameter nthreads, then fail and return false. Another possible general rule is, succeed only if we can create more than 1 threads and fail otherwise. Having more than 1 thread is the reason why we call parallel_image in the first place. Stefan
_______________________________________________ Oiio-dev mailing list [email protected] http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org
