Skip to content

Commit 8e231c2

Browse files
committed
Copy stuff over from FSharpx
1 parent c10ecf1 commit 8e231c2

17 files changed

Lines changed: 1433 additions & 75 deletions

README.md

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,25 @@
1-
[![Issue Stats](http://issuestats.com/github/fsprojects/ProjectScaffold/badge/issue)](http://issuestats.com/github/fsprojects/ProjectScaffold)
2-
[![Issue Stats](http://issuestats.com/github/fsprojects/ProjectScaffold/badge/pr)](http://issuestats.com/github/fsprojects/ProjectScaffold)
1+
[![Issue Stats](http://issuestats.com/github/fsprojects/FSharpx.Async/badge/issue)](http://issuestats.com/github/fsprojects/FSharpx.Async)
2+
[![Issue Stats](http://issuestats.com/github/fsprojects/FSharpx.Async/badge/pr)](http://issuestats.com/github/fsprojects/FSharpx.Async)
33

4-
# ProjectScaffold
4+
# FSharpx:Async [![NuGet Status](http://img.shields.io/nuget/v/FSharpx.Async.svg?style=flat)](https://www.nuget.org/packages/FSharpx.Async/)
55

6-
This project can be used to scaffold a prototypical .NET solution including file system layout and tooling. This includes a build process that:
6+
**FSharpx.Async** is a collections of async helpers for F#.
77

8-
* updates all AssemblyInfo files
9-
* compiles the application and runs all test projects
10-
* generates [SourceLinks](https://github.com/ctaggart/SourceLink)
11-
* generates API docs based on XML document tags
12-
* generates [documentation based on Markdown files](http://fsprojects.github.io/ProjectScaffold/writing-docs.html)
13-
* generates [NuGet](http://www.nuget.org) packages
14-
* and allows a simple [one step release process](http://fsprojects.github.io/ProjectScaffold/release-process.html).
8+
See [the home page](http://fsprojects.github.io/FSharpx.Async/) for details. The home page can be [edited, forked or cloned](https://github.com/fsprojects/FSharpx.Async/tree/gh-pages)
9+
Please contribute to this project. Don't ask for permission, just fork the repository and send pull requests.
1510

16-
In order to start the scaffolding process run
11+
Please also join the [F# Open Source Group](http://fsharp.github.com)
1712

18-
$ build.cmd // on windows
19-
$ build.sh // on mono
20-
21-
Read the [Getting started tutorial](http://fsprojects.github.io/ProjectScaffold/index.html#Getting-started) to learn more.
13+
# Build Status
2214

23-
Documentation: http://fsprojects.github.io/ProjectScaffold
15+
Head (branch ``master``), Windows Server 2012 (Appveyor) [![Build status](https://ci.appveyor.com/api/projects/status/jv6nki3vm2s6bmj6?svg=true)](https://ci.appveyor.com/project/SteffenForkmann/fsharpx-async)
2416

25-
## Maintainer(s)
17+
Head (branch ``master``), OSX (Travis) [![Build status](https://travis-ci.org/fsprojects/FSharpx.Async.svg?branch=master)](https://travis-ci.org/fsprojects/FSharpx.Async)
18+
19+
# Maintainer(s)
2620

2721
- [@forki](https://github.com/forki)
28-
- [@pblasucci](https://github.com/pblasucci)
29-
- [@sergey-tihon](https://github.com/sergey-tihon)
22+
- [@mausch](https://github.com/mausch)
23+
- [@panesofglass](https://github.com/panesofglass)
3024

3125
The default maintainer account for projects under "fsprojects" is [@fsgit](https://github.com/fsgit) - F# Community Project Incubation Space (repo management)

RELEASE_NOTES.md

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,2 @@
1-
### 1.0 - Unreleased
2-
* More awesome stuff coming
3-
* Added SourceLink for Source Indexing PDB
4-
5-
#### 0.5.1-beta - November 6 2013
6-
* Improved quality of solution-wide README.md files
7-
8-
#### 0.5.0-beta - October 29 2013
9-
* Improved quality of solution-wide README.md files
10-
11-
#### 0.0.1-beta - October 24 2013
12-
* Changed name from fsharp-project-scaffold to FSharp.ProjectScaffold
13-
* Initial release
1+
### 1.9.6 - 23.02.2015
2+
* Copied stuff from FSharpx

docs/content/index.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This example demonstrates using a function defined in this sample library.
2727
2828
*)
2929
#r "FSharpx.Async.dll"
30-
open FSharpx.Async
30+
open FSharpx.Control
3131

3232
printfn "hello = %i" <| Library.hello 0
3333

src/FSharpx.Async/Agent.fs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// ----------------------------------------------------------------------------
2+
// F# async extensions (Agent.fs)
3+
// (c) Tomas Petricek, 2011, Available under Apache 2.0 license.
4+
// ----------------------------------------------------------------------------
5+
namespace FSharpx.Control
6+
7+
/// Type alias for F# mailbox processor type
8+
type Agent<'T> = MailboxProcessor<'T>

src/FSharpx.Async/Async.fs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// ----------------------------------------------------------------------------
2+
// F# async extensions
3+
// (c) Tomas Petricek, David Thomas 2012, Available under Apache 2.0 license.
4+
// ----------------------------------------------------------------------------
5+
namespace FSharpx.Control
6+
open System
7+
open System.Threading
8+
9+
// ----------------------------------------------------------------------------
10+
11+
[<AutoOpen>]
12+
module AsyncExtensions =
13+
type Microsoft.FSharp.Control.Async with
14+
15+
/// Creates an asynchronous workflow that runs the asynchronous workflow
16+
/// given as an argument at most once. When the returned workflow is
17+
/// started for the second time, it reuses the result of the
18+
/// previous execution.
19+
static member Cache (input:Async<'T>) =
20+
let agent = Agent<AsyncReplyChannel<_>>.Start(fun agent -> async {
21+
let! repl = agent.Receive()
22+
let! res = input
23+
repl.Reply(res)
24+
while true do
25+
let! repl = agent.Receive()
26+
repl.Reply(res) })
27+
28+
async { return! agent.PostAndAsyncReply(id) }
29+
30+
/// Starts the specified operation using a new CancellationToken and returns
31+
/// IDisposable object that cancels the computation. This method can be used
32+
/// when implementing the Subscribe method of IObservable interface.
33+
static member StartDisposable(op:Async<unit>) =
34+
let ct = new System.Threading.CancellationTokenSource()
35+
Async.Start(op, ct.Token)
36+
{ new IDisposable with
37+
member x.Dispose() = ct.Cancel() }
38+
39+
#if NET40
40+
41+
/// Starts a non-generic Task with the cancellationToken and returns an
42+
/// Async<unit> containing the result.
43+
static member AwaitTask(task:Tasks.Task, ?cancellationToken) =
44+
let cancel = defaultArg cancellationToken Async.DefaultCancellationToken
45+
Async.AwaitTask <| task.ContinueWith<unit>((fun t -> ()), cancel)
46+
47+
/// Starts a Task<'a> with the timeout and cancellationToken and
48+
/// returns a Async<a' option> containing the result. If the Task does
49+
/// not complete in the timeout interval, or is faulted None is returned.
50+
static member TryAwaitTask(task:Tasks.Task<_>, ?timeout, ?cancellationToken) =
51+
let timeout = defaultArg timeout Timeout.Infinite
52+
let cancel = defaultArg cancellationToken Async.DefaultCancellationToken
53+
async {
54+
return
55+
if task.Wait(timeout, cancel) && not task.IsCanceled && not task.IsFaulted
56+
then Some task.Result
57+
else None }
58+
59+
/// Implements an extension method that overloads the standard
60+
/// 'Bind' of the 'async' builder. The new overload awaits on
61+
/// a standard .NET task
62+
type Microsoft.FSharp.Control.AsyncBuilder with
63+
member x.Bind(t:Tasks.Task<'T>, f:'T -> Async<'R>) : Async<'R> = async.Bind(Async.AwaitTask t, f)
64+
member x.Bind(t:Tasks.Task, f:unit -> Async<'R>) : Async<'R> = async.Bind(Async.AwaitTask t, f)
65+
66+
#endif

0 commit comments

Comments
 (0)