On 9 October 2011 19:54, Jon Olav Vik <jono...@gmail.com> wrote: > On Sun, Oct 9, 2011 at 2:57 PM, Dag Sverre Seljebotn > <d.s.seljeb...@astro.uio.no> wrote: >>>> with parallel.single(): >>>> same as master, except any thread may do the execution >>>> >>>> An optional keyword argument 'nowait' specifies whether there will be a >>>> barrier at the end. The default is to wait. >> >> I like >> >> if parallel.is_master(): >> ... >> explicit_barrier_somehow() # see below >> >> better as a Pythonization. One could easily support is_master to be used in >> other contexts as well, simply by assigning a status flag in the master >> block. >> >> Using an if-test flows much better with Python I feel, but that naturally >> lead to making the barrier explicit. But I like the barrier always being >> explicit, rather than having it as a predicate on all the different >> constructs like in OpenMP.... > > Personally, I think I'd prefer find context managers as a very > readable way to deal with parallelism, similar to the "threading" > module: > > http://docs.python.org/library/threading.html#using-locks-conditions-and-semaphores-in-the-with-statement > _______________________________________________ > cython-devel mailing list > cython-devel@python.org > http://mail.python.org/mailman/listinfo/cython-devel >
Yeah it makes a lot of sense for mutual exclusion, but 'master' really means "only the master thread executes this peace of code, even though other threads encounter the same code", which is more akin to 'if' than 'with'. _______________________________________________ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel