Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Wait until deadline variant

オープン
#231 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
30/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
wasm

調査の方向性

issue ではファイルやテストは指定されていません。まず依存関係である #230 を読み、続いて Atomics.waitAsync と、さまざまなオペレーティングシステムおよび組み込みハードウェアにおける絶対待機と相対待機についての提案の議論を確認してください。完了時には、明確なセマンティクスと、既存の期間ベースの形式との関係を備えた、期限ベースの待機バリアントが仕様化されているべきです。

索引モデルが issue の本文から書いたものです。

説明

This obviously depends on #230.

Waiting for a duration is useful for simple blocking waits, but event loops generally find deadlines more convenient to work with, since you can just throw all the deadlines into a heap, sort by deadline, and (if your loop is multi-threaded) make your wait condition include timer add/remove events. Browser runtimes would already likely need a similar model anyways because of Atomics.waitAsync, but it's easy for a runtime using one model to expose the other.

Also, the type of wait differs heavily between platforms, with some accepting absolute deadlines, some accepting relative timeouts, and some accepting both:

  • Operating systems:
    • Linux: all futex waits other than FUTEX_WAIT use absolute deadlines, and even that one has an absolute alternative documented in its manpages.
    • Fuschia only uses absolute deadlines in its zx_futex_wait syscall, and offers no relative equivalent.
    • macOS provides both os_sync_wait_on_address_with_deadline and os_sync_wait_on_address_with_timeout.
    • OpenBSD and Windows only offer relative timeouts in their APIs.
    • pthread_condvar_timedwait only uses absolute timeouts.
  • Embedded hardware:
    • 32-bit ARM's SysTick is effectively timeout-based. It decrements every tick until it hits zero, in which it then triggers an interrupt. Setting the register essentially sets the number of ticks to wait before sending the interrupt.
    • RISC-V's privileged spec uses *timecmp registers corresponding to *time targets and triggers an interrupt whenever they're equal, effectively using a deadline-based system.
    • x86-64's HPET works nearly identically to RISC-V's mechanism. (This mostly only has relevance for VM-based server-side runtimes.)
    • The real-time clock specified by ACPI for motherboards uses deadlines. (This is sometimes used on high-end microcontrollers.)

Will note that it's easy to do one in terms of the other.

  • If all waits are absolute, relative waits are as simple as using a deadline of current_time() + timeout.
  • If all waits are relative, absolute waits are as simple as using a timeout of max(target_time - current_time(), 0).
主要言語
WebAssembly
スター
769
フォーク
54
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

WebAssembly/threads のほかの issue

WebAssembly/threads の issue をすべて見る

似ている issue

Operating Systems の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。