Paradox Game Engine
v1.0.0 beta06
Main Page
Related Pages
Packages
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Events
Macros
Pages
MicroThreadSynchronizationContext.cs
Go to the documentation of this file.
1
// Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2
// This file is distributed under GPL v3. See LICENSE.md for details.
3
using
System
;
4
using
System.Threading;
5
6
namespace
SiliconStudio.Core.MicroThreading
7
{
8
public
class
MicroThreadSynchronizationContext
:
SynchronizationContext
9
{
10
internal
MicroThread
MicroThread
;
11
12
public
MicroThreadSynchronizationContext
(
MicroThread
microThread)
13
{
14
this.MicroThread = microThread;
15
}
16
17
public
override
SynchronizationContext
CreateCopy
()
18
{
19
return
this
;
20
}
21
22
public
override
void
Post
(SendOrPostCallback d,
object
state)
23
{
24
// There is two case:
25
// 1/ We are either in normal MicroThread inside Scheduler.Step() (CurrentThread test),
26
// in which case we will directly execute the callback to avoid further processing from scheduler.
27
// Also, note that Wait() sends us event that are supposed to come back into scheduler.
28
// Note: As it will end up on the callstack, it might be better to Schedule it instead (to avoid overflow)?
29
// 2/ Otherwise, we just received an external task continuation (i.e. TaskEx.Sleep()), or a microthread triggering another,
30
// so schedule it so that it comes back in our regular scheduler.
31
if
(
MicroThread
.
Scheduler
.
RunningMicroThread
==
MicroThread
)
32
{
33
d(state);
34
}
35
else
if
(
MicroThread
.
State
==
MicroThreadState
.Completed)
36
{
37
throw
new
InvalidOperationException(
"MicroThread is already completed but still posting continuations."
);
38
}
39
else
40
{
41
MicroThread.ScheduleContinuation(
MicroThread.ScheduleMode
, d, state);
42
}
43
}
44
}
45
}
SynchronizationContext
SiliconStudio.Core.MicroThreading.MicroThread
Represents an execution context managed by a Scheduler, that can cooperatively yield execution to ano...
Definition:
MicroThread.cs:16
SiliconStudio.Core.MicroThreading.Scheduler.RunningMicroThread
MicroThread RunningMicroThread
Gets the current running micro thread in this scheduler through Run.
Definition:
Scheduler.cs:51
SiliconStudio.Core.MicroThreading.MicroThreadSynchronizationContext.CreateCopy
override SynchronizationContext CreateCopy()
Definition:
MicroThreadSynchronizationContext.cs:17
SiliconStudio.Core.MicroThreading.MicroThreadSynchronizationContext.MicroThreadSynchronizationContext
MicroThreadSynchronizationContext(MicroThread microThread)
Definition:
MicroThreadSynchronizationContext.cs:12
SiliconStudio.Shaders.Parser.System
A system file.
SiliconStudio.Core.MicroThreading.MicroThreadState
MicroThreadState
Definition:
MicroThreadState.cs:5
SiliconStudio.Core.MicroThreading.MicroThreadSynchronizationContext
Definition:
MicroThreadSynchronizationContext.cs:8
SiliconStudio.Core.MicroThreading.MicroThread.State
MicroThreadState State
Gets the state of this MicroThread.
Definition:
MicroThread.cs:126
SiliconStudio.Core.MicroThreading.MicroThreadSynchronizationContext.Post
override void Post(SendOrPostCallback d, object state)
Definition:
MicroThreadSynchronizationContext.cs:22
SiliconStudio.Core.MicroThreading.ScheduleMode
ScheduleMode
Definition:
ScheduleMode.cs:5
SiliconStudio.Core.MicroThreading.MicroThread.Scheduler
Scheduler Scheduler
Gets the scheduler associated with this MicroThread.
Definition:
MicroThread.cs:120
sources
common
core
SiliconStudio.Core.MicroThreading
MicroThreadSynchronizationContext.cs
Generated on Sat Dec 20 2014 21:51:05 for Paradox Game Engine by
1.8.7