Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ตัวแปร frame

หมายเหตุ: ฟังก์ชันนี้ยังพัฒนาไม่เสร็จสมบูรณ์! จะมีเอกสารเพิ่มเติมตามมาหลังการพัฒนา!

หากตัวแปรถูกทำเครื่องหมายเป็น frame ตัวแปรเองจะถูกเก็บไว้บนเฟรมที่ทำงานอยู่ของฟังก์ชัน ดังนั้นตัวแปรนี้จึงอยู่ในสโคปของทุกโพรบในเฟรมที่ทำงานอยู่นั้น ค่าของตัวแปรนี้จะคงที่ตลอดการเข้าถึงของโพรบ ตราบใดที่เฟรมของฟังก์ชันนั้นยังทำงานอยู่

คุณจึงใช้ตัวแปรนี้เก็บข้อมูลสำหรับอีเวนต์ที่โพรบระหว่างการทำงานของฟังก์ชันหนึ่งๆได้

ตัวอย่าง:

// Tracks all of the runtimes of each function invocation across program execution.
use time;
wasm:func:entry {
    frame var start: u32;
    start = time.now();
}
wasm:func:exit {
    frame var start: u32;
    unshared var elapsed: vec<u32>;
    elapsed.push(time.now() - start);
}