Skip to content

Commit e080acd

Browse files
committed
Add signature files for taskSeq and builders, plus utils, hide debug stuff etc
1 parent 5f1f9e4 commit e080acd

File tree

9 files changed

+661
-629
lines changed

9 files changed

+661
-629
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace TaskSeq.Tests
2+
3+
open System.Runtime.CompilerServices
4+
5+
// ensure the test project has access to the internal types
6+
[<assembly: InternalsVisibleToAttribute("FSharp.Control.TaskSeq.Test")>]
7+
8+
do ()
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
namespace FSharp.Control
2+
3+
open System.Threading.Tasks
4+
open System
5+
open System.Diagnostics
6+
open System.Threading
7+
8+
type Debug =
9+
10+
[<DefaultValue(false)>]
11+
static val mutable private verbose: bool option
12+
13+
/// Setting from environment variable TASKSEQ_LOG_VERBOSE, which,
14+
/// when set, enables (very) verbose printing of flow and state
15+
static member private getVerboseSetting() =
16+
match Debug.verbose with
17+
| None ->
18+
let verboseEnv =
19+
try
20+
match Environment.GetEnvironmentVariable "TASKSEQ_LOG_VERBOSE" with
21+
| null -> false
22+
| x ->
23+
match x.ToLowerInvariant().Trim() with
24+
| "1"
25+
| "true"
26+
| "on"
27+
| "yes" -> true
28+
| _ -> false
29+
30+
with _ ->
31+
false
32+
33+
Debug.verbose <- Some verboseEnv
34+
verboseEnv
35+
36+
| Some setting -> setting
37+
38+
/// Private helper to log to stdout in DEBUG builds only
39+
[<Conditional("DEBUG")>]
40+
static member private print value =
41+
match Debug.getVerboseSetting () with
42+
| false -> ()
43+
| true ->
44+
// don't use ksprintf here, because the compiler does not remove all allocations due to
45+
// the way PrintfFormat types are compiled, even if we set the Conditional attribute.
46+
let ct = Thread.CurrentThread
47+
printfn "%i (%b): %s" ct.ManagedThreadId ct.IsThreadPoolThread value
48+
49+
/// Log to stdout in DEBUG builds only
50+
[<Conditional("DEBUG")>]
51+
static member logInfo(str) = Debug.print str
52+
53+
/// Log to stdout in DEBUG builds only
54+
[<Conditional("DEBUG")>]
55+
static member logInfo(str, data) = Debug.print $"%s{str}{data}"

src/FSharp.Control.TaskSeq/FSharp.Control.TaskSeq.fsproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,27 @@ Generates optimized IL code through the new resumable state machines, and comes
2626
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
2727
</PropertyGroup>
2828

29+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
30+
<OtherFlags></OtherFlags>
31+
</PropertyGroup>
32+
33+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
34+
<OtherFlags></OtherFlags>
35+
<Tailcalls>True</Tailcalls>
36+
</PropertyGroup>
37+
2938
<ItemGroup>
3039
<Content Include="..\..\release-notes.txt" Link="release-notes.txt" />
3140
<None Include="..\..\assets\taskseq-icon.png">
3241
<Pack>True</Pack>
3342
<PackagePath>\</PackagePath>
3443
</None>
3544
<None Include="..\..\assets\nuget-package-readme.md" Pack="true" PackagePath="" />
45+
<Compile Include="AssemblyInfo.fs" />
46+
<Compile Include="DebugUtils.fs" />
47+
<Compile Include="Utils.fsi" />
3648
<Compile Include="Utils.fs" />
49+
<Compile Include="TaskSeqBuilder.fsi" />
3750
<Compile Include="TaskSeqBuilder.fs" />
3851
<Compile Include="TaskSeqInternal.fs" />
3952
<Compile Include="TaskSeq.fsi" />

0 commit comments

Comments
 (0)