Skip to content

feat: implement sleep/delay function #24

@mjm918

Description

@mjm918

Summary

Add sleep/delay capability to naml runtime for timing control in games and applications.

Proposed API

// Sleep for specified milliseconds
fn sleep(ms: int);

Use Cases

  • Game loops (controlling frame rate)
  • Rate limiting
  • Animations
  • Polling intervals

Implementation Notes

  • Block execution for specified duration
  • Platform considerations:
    • Native: std::thread::sleep
    • Server WASM: WASI poll_oneoff or busy wait
    • Browser: Not directly applicable (use async/setTimeout)

Acceptance Criteria

  • sleep(ms) pauses execution for approximately ms milliseconds
  • Accepts values from 0 to at least 60000 (1 minute)
  • Works on native platform

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions