Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > ec5844e219498f2057da8f8f3070d4a1 > files > 263

ghc-MissingH-devel-1.1.0.3-2.fc14.i686.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<!-- Generated by HsColour, http://www.cs.york.ac.uk/fp/darcs/hscolour/ -->
<title>src/Control/Concurrent/Thread/Utils.hs</title>
<link type='text/css' rel='stylesheet' href='hscolour.css' />
</head>
<body>
<pre><a name="line-1"></a><span class='hs-comment'>{- arch-tag: Thread utilities main file
<a name="line-2"></a>Copyright (C) 2004 John Goerzen &lt;jgoerzen@complete.org&gt;
<a name="line-3"></a>
<a name="line-4"></a>This program is free software; you can redistribute it and/or modify
<a name="line-5"></a>it under the terms of the GNU General Public License as published by
<a name="line-6"></a>the Free Software Foundation; either version 2 of the License, or
<a name="line-7"></a>(at your option) any later version.
<a name="line-8"></a>
<a name="line-9"></a>This program is distributed in the hope that it will be useful,
<a name="line-10"></a>but WITHOUT ANY WARRANTY; without even the implied warranty of
<a name="line-11"></a>MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
<a name="line-12"></a>GNU General Public License for more details.
<a name="line-13"></a>
<a name="line-14"></a>You should have received a copy of the GNU General Public License
<a name="line-15"></a>along with this program; if not, write to the Free Software
<a name="line-16"></a>Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
<a name="line-17"></a>-}</span>
<a name="line-18"></a>
<a name="line-19"></a><span class='hs-comment'>{- |
<a name="line-20"></a>   Module     : Control.Concurrent.Thread.Utils
<a name="line-21"></a>   Copyright  : Copyright (C) 2004 John Goerzen
<a name="line-22"></a>   License    : GNU GPL, version 2 or above
<a name="line-23"></a>
<a name="line-24"></a>   Maintainer : John Goerzen &lt;jgoerzen@complete.org&gt; 
<a name="line-25"></a>   Stability  : provisional
<a name="line-26"></a>   Portability: portable
<a name="line-27"></a>
<a name="line-28"></a>This module provides various helpful utilities for dealing with threads.
<a name="line-29"></a>
<a name="line-30"></a>Written by John Goerzen, jgoerzen\@complete.org
<a name="line-31"></a>-}</span>
<a name="line-32"></a>
<a name="line-33"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Concurrent</span><span class='hs-varop'>.</span><span class='hs-conid'>Thread</span><span class='hs-varop'>.</span><span class='hs-conid'>Utils</span><span class='hs-layout'>(</span><span class='hs-comment'>-- * I\/O utilities</span>
<a name="line-34"></a>                        <span class='hs-varid'>runInThread</span>
<a name="line-35"></a>                       <span class='hs-layout'>)</span>
<a name="line-36"></a><span class='hs-keyword'>where</span>
<a name="line-37"></a>
<a name="line-38"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Concurrent</span>
<a name="line-39"></a>
<a name="line-40"></a><span class='hs-comment'>{- | Takes a IO action and a function.  The IO action will be called in a 
<a name="line-41"></a>separate thread.  When it is completed, the specified function is called with
<a name="line-42"></a>its result.  This is a simple way of doing callbacks. -}</span>
<a name="line-43"></a>
<a name="line-44"></a><a name="runInThread"></a><span class='hs-definition'>runInThread</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>IO</span> <span class='hs-varid'>a</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-layout'>(</span><span class='hs-varid'>a</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-conid'>IO</span> <span class='hs-varid'>b</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-&gt;</span> <span class='hs-conid'>IO</span> <span class='hs-conid'>ThreadId</span>
<a name="line-45"></a><span class='hs-definition'>runInThread</span> <span class='hs-varid'>action</span> <span class='hs-varid'>callback</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>forkIO</span> <span class='hs-varop'>$</span> <span class='hs-varid'>action</span> <span class='hs-varop'>&gt;&gt;=</span> <span class='hs-varid'>callback</span> <span class='hs-varop'>&gt;&gt;</span> <span class='hs-varid'>return</span> <span class='hs-conid'>()</span>
</pre></body>
</html>