Skip to content

Commit 93d3dd3

Browse files
committed
* added Aardvark.Build references
* added `clist.UpdateTo(seq, list, array)`
1 parent 2c3ac81 commit 93d3dd3

17 files changed

Lines changed: 205 additions & 17 deletions

File tree

.vscode/launch.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"program": "${workspaceFolder}/bin/Debug/net6.0/EventInterop.dll",
1313
"args": [],
1414
"cwd": "${workspaceFolder}",
15-
"console": "integratedTerminal",
15+
"console": "internalConsole",
1616
"stopAtEntry": false
1717
},
1818
{
@@ -23,7 +23,7 @@
2323
"program": "${workspaceFolder}/bin/Debug/net6.0/CSharpInterop.dll",
2424
"args": [],
2525
"cwd": "${workspaceFolder}",
26-
"console": "integratedTerminal",
26+
"console": "internalConsole",
2727
"stopAtEntry": false
2828
},
2929
{
@@ -34,18 +34,19 @@
3434
"program": "${workspaceFolder}/bin/Debug/net6.0/FSharp.Data.Adaptive.Tests.dll",
3535
"args": [],
3636
"cwd": "${workspaceFolder}",
37-
"console": "integratedTerminal",
37+
"console": "internalConsole",
3838
"stopAtEntry": false
3939
},
4040
{
41-
"name": "Fable",
42-
"type": "node",
41+
"name": "Scratch",
42+
"type": "coreclr",
4343
"request": "launch",
44-
"program": "${workspaceFolder}/node_modules/webpack-dev-server/bin/webpack-dev-server.js",
44+
"preLaunchTask": "build",
45+
"program": "${workspaceFolder}/bin/Debug/net6.0/Scratch.dll",
4546
"args": [],
4647
"cwd": "${workspaceFolder}",
47-
"console": "integratedTerminal",
48-
"stopOnEntry": false
48+
"console": "internalConsole",
49+
"stopAtEntry": false
4950
}
5051
]
5152
}

FSharp.Data.Adaptive.sln

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Microsoft Visual Studio Solution File, Format Version 12.00
1+
Microsoft Visual Studio Solution File, Format Version 12.00
22
# Visual Studio Version 16
33
VisualStudioVersion = 16.0.29215.179
44
MinimumVisualStudioVersion = 10.0.40219.1
@@ -22,6 +22,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{3F9BDA4B-D
2222
EndProject
2323
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FileSystem", "src\Demo\FileSystem\FileSystem.fsproj", "{2AE99C0D-703D-4042-9E8D-BF8A66284B0D}"
2424
EndProject
25+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Scratch", "src\Demo\Scratch\Scratch.fsproj", "{929BB872-3FFF-48E6-ABC7-3E1FB3E72242}"
26+
EndProject
2527
Global
2628
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2729
Debug|Any CPU = Debug|Any CPU
@@ -60,6 +62,10 @@ Global
6062
{2AE99C0D-703D-4042-9E8D-BF8A66284B0D}.Debug|Any CPU.Build.0 = Debug|Any CPU
6163
{2AE99C0D-703D-4042-9E8D-BF8A66284B0D}.Release|Any CPU.ActiveCfg = Release|Any CPU
6264
{2AE99C0D-703D-4042-9E8D-BF8A66284B0D}.Release|Any CPU.Build.0 = Release|Any CPU
65+
{929BB872-3FFF-48E6-ABC7-3E1FB3E72242}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
66+
{929BB872-3FFF-48E6-ABC7-3E1FB3E72242}.Debug|Any CPU.Build.0 = Debug|Any CPU
67+
{929BB872-3FFF-48E6-ABC7-3E1FB3E72242}.Release|Any CPU.ActiveCfg = Release|Any CPU
68+
{929BB872-3FFF-48E6-ABC7-3E1FB3E72242}.Release|Any CPU.Build.0 = Release|Any CPU
6369
EndGlobalSection
6470
GlobalSection(SolutionProperties) = preSolution
6571
HideSolutionNode = FALSE
@@ -71,6 +77,7 @@ Global
7177
{B978F3DF-9F10-493E-97E9-0248491D41D9} = {B5A29D79-4C76-4148-A69F-814ED1BEEFCE}
7278
{D4058F6D-A8D5-4587-AE05-D32A3B99B625} = {B5A29D79-4C76-4148-A69F-814ED1BEEFCE}
7379
{2AE99C0D-703D-4042-9E8D-BF8A66284B0D} = {B5A29D79-4C76-4148-A69F-814ED1BEEFCE}
80+
{929BB872-3FFF-48E6-ABC7-3E1FB3E72242} = {B5A29D79-4C76-4148-A69F-814ED1BEEFCE}
7481
EndGlobalSection
7582
GlobalSection(ExtensibilityGlobals) = postSolution
7683
SolutionGuid = {0E91AEEA-75F2-484D-8E5E-E3322D13C65A}

RELEASE_NOTES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### 1.2.10
2+
* added `clist.UpdateTo(seq, list, array)`
3+
* fixed AssemblyVersions
4+
15
### 1.2.9
26
* new `AList.sub` implementation
37
* switched to `aardpack` based build with CI publishing

paket.dependencies

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ framework: auto-detect
55

66
nuget FSharp.Core >= 4.7.0 lowest_matching: true
77
nuget System.Reflection.Emit.Lightweight >= 4.6.0 lowest_matching: true
8+
nuget Aardvark.Build ~> 1.0.11
89

910
# Tests : intentionally in main group
1011
nuget FsUnit ~> 3.4.1
@@ -17,4 +18,4 @@ nuget BenchmarkDotNet ~> 0.12.0
1718

1819
# Fable demo
1920
nuget Fable.Core ~> 3.2.5
20-
nuget Fable.Browser.Dom ~> 1.1.0
21+
nuget Fable.Browser.Dom ~> 1.1.0

paket.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ STORAGE: NONE
33
RESTRICTION: || (== net6.0) (== netcoreapp3.1) (== netstandard2.0)
44
NUGET
55
remote: https://api.nuget.org/v3/index.json
6+
Aardvark.Build (1.0.11)
67
BenchmarkDotNet (0.12.1)
78
BenchmarkDotNet.Annotations (>= 0.12.1)
89
CommandLineParser (>= 2.4.3)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
FSharp.Core
2-
System.Reflection.Emit.Lightweight
2+
System.Reflection.Emit.Lightweight
3+
Aardvark.Build
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
FSharp.Core
2-
BenchmarkDotNet
2+
BenchmarkDotNet
3+
Aardvark.Build
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
FSharp.Core
1+
FSharp.Core
2+
Aardvark.Build
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
FSharp.Core
1+
FSharp.Core
2+
Aardvark.Build

src/Demo/Scratch/Program.fs

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
open System
2+
open System.IO
3+
open System.Threading
4+
open FSharp.Data.Adaptive
5+
6+
module AList =
7+
open System.Threading.Tasks
8+
9+
type private AsyncSignal(isSet : bool) =
10+
let mutable isSet = isSet
11+
let mutable tcs : option<TaskCompletionSource<unit>> = None
12+
13+
member x.Pulse() =
14+
lock x (fun () ->
15+
if not isSet then
16+
isSet <- true
17+
match tcs with
18+
| Some t ->
19+
t.SetResult()
20+
tcs <- None
21+
| None ->
22+
()
23+
tcs <- None
24+
)
25+
26+
member x.Wait() =
27+
lock x (fun () ->
28+
if isSet then
29+
isSet <- false
30+
Task.FromResult()
31+
else
32+
match tcs with
33+
| Some tcs ->
34+
tcs.Task
35+
| None ->
36+
let t = TaskCompletionSource<unit>()
37+
tcs <- Some t
38+
t.Task
39+
)
40+
41+
let observe (action : IndexList<'a> -> IndexListDelta<'a> -> IndexList<'a> -> unit) (list : alist<'a>) =
42+
let reader = list.GetReader()
43+
let action = OptimizedClosures.FSharpFunc<_,_,_,_>.Adapt action
44+
let mutable running = true
45+
let signal = AsyncSignal(true)
46+
let sub = reader.AddMarkingCallback signal.Pulse
47+
48+
Async.Start <|
49+
async {
50+
while running do
51+
do! Async.AwaitTask (signal.Wait())
52+
if running then
53+
do! Async.SwitchToThreadPool()
54+
55+
let mutable oldState = IndexList.empty
56+
let mutable newState = IndexList.empty
57+
let mutable ops = IndexListDelta.empty
58+
lock reader (fun () ->
59+
oldState <- reader.State
60+
ops <- reader.GetChanges AdaptiveToken.Top
61+
newState <- reader.State
62+
)
63+
if ops.Count > 0 then action.Invoke(oldState, ops, newState)
64+
65+
}
66+
67+
let shutdown() =
68+
sub.Dispose()
69+
running <- false
70+
signal.Pulse()
71+
72+
{ new IDisposable with
73+
member x.Dispose() = shutdown()
74+
}
75+
76+
77+
let a = clist []
78+
79+
let sub =
80+
a |> AList.observe (fun oldState ops newState ->
81+
printfn "thread: %d" Thread.CurrentThread.ManagedThreadId
82+
printfn " old: %0A" (IndexList.toList oldState)
83+
printfn " new: %0A" (IndexList.toList newState)
84+
)
85+
86+
let rand = Random()
87+
for i in 1 .. 10 do
88+
let l = rand.Next(20)
89+
let list = List.init l (fun _ -> rand.Next(20))
90+
transact(fun () -> a.UpdateTo list |> ignore)
91+
printfn "changed"
92+
Thread.Sleep 1000
93+
94+
sub.Dispose()
95+
96+
let l = rand.Next(20)
97+
let list = List.init l (fun _ -> rand.Next(20))
98+
transact(fun () -> a.UpdateTo list |> ignore)
99+
printfn "changed"
100+
Thread.Sleep 1000

0 commit comments

Comments
 (0)