LE:關於死機問題看到這些開放的錯誤:Bug 566324,Bug 580791,Bug 602502
我是相當新的這個我自己,我在這裏我迄今收集的信息。也許它會有用。 1)Mono.Tasklets庫(由Miguel de Icaza描述[閱讀:here])是一個連續庫,可用於構造各種形式的連續系統和輕量級(LW)線程。
一個簡單的方法來描述這是C的longjmp/setjmp的單語版本,它們只能用於展開堆棧。
庫最初是由一個人開發的[閱讀:here]現在它包含在單和記錄[閱讀:here(跟隨這些鏈接,你會發現更多的信息)
那傢伙實施在這個抽象之上的微線程庫。現在已移植到Mono.Tasklets框架
2)continuation是一個對象,可用於存儲當前的執行狀態,然後可用於稍後恢復存儲的狀態。
此處的「執行狀態」表示堆棧,其中包括調用堆棧和局部變量以及處理器的寄存器。
當存儲狀態恢復時,程序執行看起來像跳回到保存狀態的位置,並恢復所有局部變量。上Wikipedia/Continuations
3)API
An example in C.等詳細信息是:
public class Continuation {
public Continuation();
public void Mark();
public int Store (int state);
public void Restore (int state);
}
延續可用於實現微螺紋。你可以看看Mono的代碼。在Github上可用的微螺紋[READ:here]
public Continuation()
{
m_handle = alloc_continuation();
Print("Continuation()");
}
public void Mark()
{
Print("Mark()");
// skip 1 frame, ie. this function
mark_continuation_frame(m_handle, 1);
}
public int Store(int data)
{
Print("Store({0})", data);
int res = store_continuation(m_handle, data);
Print("Store({0}) = {1}", data, res);
return res;
}
public void Restore(int data)
{
Print("Restore({0})", data);
restore_continuation(m_handle, data);
Print("Restore() exit (NEVER REACHED)");
}
從呈現什麼here:
馬克()它用於標記的最頂層幀被存儲
Store(x)將當前狀態存儲到繼續,並返回給定的整數x。
還原(y)恢復存儲的狀態,並返回給定的整數y。 (注意:給恢復整數y實際上是從商店()方法返回,因爲這是我們的狀態有所恢復後)。
static void Main()
{
Continuation c = new Continuation();
c.Mark();
int foo = 123;
int val = c.Store(0);
Console.WriteLine("{0} {1}", val, foo);
foo = 321;
if (val < 5)
c.Restore(val + 1);
}
當你調用存儲()的當前狀態執行被記錄下來並且可以通過調用Restore()返回到這個狀態。
呼叫者存儲()告訴它是否是基於結果從存儲初始存儲或還原點:
var c = new Continuation();
...
switch (c.Store (0)){
case 0:
// First invocation
case 1:
// Restored from the point ahead.
}
...
// Jump back to the switch statement.
c.Restore (1);
的monoco鏈接+特別是你的總結是極其有幫助 - 謝謝! – 2010-07-26 15:50:05