[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Optionally make use of 'parallel' in a package

From: Daniel Kraft
Subject: Optionally make use of 'parallel' in a package
Date: Thu, 12 Mar 2015 13:08:01 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0


In a package (level-set, to be precise) I want to make use of
'pararrayfun' of the parallel package to utilise parallel computation.
However, I do not want to make level-set strongly dependent on parallel.
 Instead, I would like to simply fall back to single threading when the
parallel package is not installed.

For this, I see two "problems" that I need to solve:

1) Decide whether or not a particular package (in this case, 'parallel')
is installed.  I think this is possible with both the 'pkg' and 'ver'
functions.  Is there some recommended way to do it?

2) If present, make sure that 'parallel' is loaded when I need it.  I
could use 'pkg load' / 'pkg unload' calls in PKG_ADD / PKG_DEL or the
called function itself.  However, this would mess with the user's
environment, right?  Is there a way to ensure that the package is loaded
only temporarily during my function without modifying the global

Thank you a lot!  Yours,

OpenPGP: 1142 850E 6DFF 65BA 63D6  88A8 B249 2AC4 A733 0737
Namecoin: id/domob ->
Done:  Arc-Bar-Cav-Hea-Kni-Ran-Rog-Sam-Tou-Val-Wiz
To go: Mon-Pri

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]