Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit96dd484

Browse files
committed
FX_NO_SYNC_CONTEXT ---- dead code removal
1 parente789aca commit96dd484

File tree

3 files changed

+2
-33
lines changed

3 files changed

+2
-33
lines changed

‎src/fsharp/FSharp.Core/control.fs‎

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,13 @@ namespace Microsoft.FSharp.Control
193193

194194
static letunfake FakeUnit=()
195195
// preallocate context-switching callbacks
196-
#if!FX_NO_SYNC_CONTEXT
197196
// Preallocate the delegate
198197
// This should be the only call to SynchronizationContext.Post in this library. We must always install a trampoline.
199198
letsendOrPostCallback=
200199
SendOrPostCallback(fun o->
201200
letf= unbox o: unit-> FakeUnitValue
202201
this.Protect f|> unfake
203202
)
204-
#endif
205203

206204
// Preallocate the delegate
207205
// This should be the only call to QueueUserWorkItem in this library. We must always install a trampoline.
@@ -220,11 +218,9 @@ namespace Microsoft.FSharp.Control
220218
)
221219
#endif
222220

223-
#if!FX_NO_SYNC_CONTEXT
224221
memberthis.Post(ctxt:SynchronizationContext)(f:unit->FakeUnitValue)=
225222
ctxt.Post(sendOrPostCallback, state=(f|> box))
226223
FakeUnit
227-
#endif
228224

229225
memberthis.QueueWorkItem(f:unit->FakeUnitValue)=
230226
ifnot(ThreadPool.QueueUserWorkItem(waitCallbackForQueueWorkItemWithTrampoline, f|> box))then
@@ -643,11 +639,9 @@ namespace Microsoft.FSharp.Control
643639
//----------------------------------
644640
// DERIVED SWITCH TO HELPERS
645641

646-
#if!FX_NO_SYNC_CONTEXT
647642
letswitchTo(ctxt:SynchronizationContext)=
648643
protectedPrimitive(fun({aux=aux}asargs)->
649644
aux.trampolineHolder.Post ctxt(fun()-> args.cont()))
650-
#endif
651645

652646
letswitchToNewThread()=
653647
protectedPrimitive(fun({aux=aux}asargs)->
@@ -670,14 +664,8 @@ namespace Microsoft.FSharp.Control
670664
}
671665
}
672666

673-
#if FX_NO_SYNC_CONTEXT
674-
letgetSyncContext _=null
675-
letdelimitSyncContext args= args
676-
letpostOrQueue _(trampolineHolder:TrampolineHolder)f=
677-
trampolineHolder.QueueWorkItem f
678-
#else
679667
letgetSyncContext()= System.Threading.SynchronizationContext.Current
680-
668+
681669
letpostOrQueue(ctxt:SynchronizationContext)(trampolineHolder:TrampolineHolder)f=
682670
match ctxtwith
683671
|null-> trampolineHolder.QueueWorkItem f
@@ -697,9 +685,6 @@ namespace Microsoft.FSharp.Control
697685
ccont=(fun x-> trampolineHolder.Post ctxt(fun()-> aux.ccont x))
698686
}
699687
}
700-
701-
#endif
702-
703688

704689
// When run, ensures that each of the continuations of the process are run in the same synchronization context.
705690
letprotectedPrimitiveWithResync f=
@@ -730,19 +715,14 @@ namespace Microsoft.FSharp.Control
730715
[<AutoSerializable(false)>]
731716
typeSuspendedAsync<'T>(args:AsyncParams<'T>)=
732717
letctxt= getSyncContext()
733-
#if!FX_NO_SYNC_CONTEXT
734718
letthread=
735719
match ctxtwith
736720
|null->null// saving a thread-local access
737721
|_-> Thread.CurrentThread
738-
#endif
739722
lettrampolineHolder= args.aux.trampolineHolder
740723
memberthis.ContinueImmediate res=
741724
letaction()= args.cont res
742725
let inlineexecuteImmediately()= trampolineHolder.Protect action
743-
#if FX_NO_SYNC_CONTEXT
744-
executeImmediately()
745-
#else
746726
letcurrentCtxt= System.Threading.SynchronizationContext.Current
747727
match ctxt, currentCtxtwith
748728
|null,null->
@@ -753,8 +733,7 @@ namespace Microsoft.FSharp.Control
753733
executeImmediately()
754734
|_->
755735
postOrQueue ctxt trampolineHolder action
756-
#endif
757-
736+
758737
memberthis.ContinueWithPostOrQueue res=
759738
postOrQueue ctxt trampolineHolder(fun()-> args.cont res)
760739

@@ -1679,8 +1658,6 @@ namespace Microsoft.FSharp.Control
16791658

16801659
return Async.AsyncWaitAsyncWithTimeout(innerCTS, resultCell,millisecondsTimeout)}
16811660

1682-
#if!FX_NO_SYNC_CONTEXT
1683-
16841661
static memberSwitchToContext syncContext=
16851662
async{match syncContextwith
16861663
|null->
@@ -1689,7 +1666,6 @@ namespace Microsoft.FSharp.Control
16891666
| ctxt->
16901667
// post the continuation to the synchronization context
16911668
return! switchTo ctxt}
1692-
#endif
16931669

16941670
static memberOnCancel action=
16951671
async{let!ct= getCancellationToken()

‎src/fsharp/FSharp.Core/control.fsi‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,16 +199,13 @@ namespace Microsoft.FSharp.Control
199199
/// <returns>A computation that generates a new work item in the thread pool.</returns>
200200
static memberSwitchToThreadPool:unit->Async<unit>
201201

202-
#if!FX_NO_SYNC_CONTEXT
203202
/// <summary>Creates an asynchronous computation that runs
204203
/// its continuation using syncContext.Post. If syncContext is null
205204
/// then the asynchronous computation is equivalent to SwitchToThreadPool().</summary>
206205
/// <param name="syncContext">The synchronization context to accept the posted computation.</param>
207206
/// <returns>An asynchronous computation that uses the syncContext context to execute.</returns>
208207
static memberSwitchToContext:syncContext:System.Threading.SynchronizationContext->Async<unit>
209-
#endif
210208

211-
212209
/// <summary>Creates an asynchronous computation that captures the current
213210
/// success, exception and cancellation continuations. The callback must
214211
/// eventually call exactly one of the given continuations.</summary>

‎tests/fsharpqa/Source/Misc/AsyncOperations.fs‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,11 @@ namespace Microsoft.FSharp.Control
4848
|[]->()
4949
|[cont]when reuseThread-> cont res
5050
| otherwise->
51-
#if FX_NO_SYNC_CONTEXT
52-
letpostOrQueue cont= ThreadPool.QueueUserWorkItem(fun _-> cont res)|> ignore
53-
#else
5451
letsynchContext= System.Threading.SynchronizationContext.Current
5552
letpostOrQueue=
5653
match synchContextwith
5754
|null->fun cont-> ThreadPool.QueueUserWorkItem(fun _-> cont res)|> ignore
5855
| sc->fun cont-> sc.Post((fun _-> cont res), state=null)
59-
#endif
6056
grabbedConts|> List.iter postOrQueue
6157

6258
/// Get the reified result

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp