Package frege.lib.ForkJoin

Compiled: Wed Dec 05 00:08:24 PST 2012 from source file: frege/lib/ForkJoin.fr

Package Documentation

Copyright © 2011, Ingo Wechsung

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Support for ad hoc parallelism in Frege through java's ForkJoin mechanism

Whenever a Frege module contains a main function, the compiler generates an appropriate Java main method, which will call frege.RT.fjMain.

This method checks the frege.parallel system property to see if parallelism is desired, and if so, creates a fork join pool and starts an initial task which happens to run the main IO action of the Frege module.

If parallelism is not desired, the main action is just evaluated in the current thread.

The user can turn off parallelism by passing -Dfrege.parallel=false to the Java interpreter.

This mechanism works only if frege code will be entered through the main() method of some frege module, i.e if it is started from the command line. In frege code, fork\/join tasks are created only if the code annotated with par runs itself in a fork/join task.

Table of Content

Imports

Functions and Values

$| :: (α->β) -> α -> β
usage
f $| a

Equivalent to a `par` f a

:| :: α -> [α] -> [α]
usage
a :| as

Equivalent to parOp (:) a as

mapP :: (α->β) -> [α] -> [β]
usage
mapP f xs

Like map, but applies the function parallel to mapping the rest of the list. It does therefore not work with infinite lists.

par :: α -> β -> β
usage
a `par` b

Fork evaluation of a and return b. In sequential mode, this will be equivalent to snd (a,b)

parOp :: (α->γ->β) -> α -> γ -> β
usage
parOp f a b

Equivalent to a `par` b `par` f a b

Functions and Values by Type

α -> [α] -> [α]

:|

(α->β) -> [α] -> [β]

mapP

(α->β) -> α -> β

$|

α -> β -> β

par

(α->γ->β) -> α -> γ -> β

parOp

Valid HTML 4.01 Strict