[wait_queue] Method to peek the wait queue head

Adds a method to peek the thread that is at the head of the wait queue.
Updates the C++ WaitQueue wrapper and brings back some previously removed wrappers.

Test: Still compiles. No functional changes.
Change-Id: I5244c13bc1ef7ae53c23d27bb3cc5977d9fbd990
diff --git a/kernel/include/kernel/wait.h b/kernel/include/kernel/wait.h
index fbe9339..2b25e58 100644
--- a/kernel/include/kernel/wait.h
+++ b/kernel/include/kernel/wait.h
@@ -62,6 +62,10 @@
 
 int wait_queue_blocked_priority(wait_queue_t*) TA_REQ(thread_lock);
 
+// returns the current highest priority blocked thread on this wait queue, or
+// null if no threads are blocked.
+struct thread* wait_queue_peek(wait_queue_t*) TA_REQ(thread_lock);
+
 // release one or more threads from the wait queue.
 // reschedule = should the system reschedule if any is released.
 // wait_queue_error = what wait_queue_block() should return for the blocking thread.
@@ -105,10 +109,21 @@
         return wait_queue_block(&wq_, deadline);
     }
 
+    struct thread* Peek() TA_REQ(thread_lock) {
+        return wait_queue_peek(&wq_);
+    }
+
     int WakeOne(bool reschedule, zx_status_t wait_queue_error) TA_REQ(thread_lock) {
         return wait_queue_wake_one(&wq_, reschedule, wait_queue_error);
     }
 
+    bool IsEmpty() TA_REQ(thread_lock) { return wait_queue_is_empty(&wq_); }
+
+    static zx_status_t UnblockThread(struct thread* t, zx_status_t wait_queue_error)
+        TA_REQ(thread_lock) {
+        return wait_queue_unblock_thread(t, wait_queue_error);
+    }
+
 private:
     wait_queue_t wq_ = WAIT_QUEUE_INITIAL_VALUE(wq_);
 };
diff --git a/kernel/kernel/wait.cpp b/kernel/kernel/wait.cpp
index f147908..5095929 100644
--- a/kernel/kernel/wait.cpp
+++ b/kernel/kernel/wait.cpp
@@ -176,6 +176,11 @@
     return t->effec_priority;
 }
 
+// returns a reference to the highest priority thread queued
+thread_t* wait_queue_peek(wait_queue_t* wait) {
+    return list_peek_head_type(&wait->heads, thread_t, wait_queue_heads_node);
+}
+
 static void wait_queue_timeout_handler(timer_t* timer, zx_time_t now,
                                        void* arg) {
     thread_t* thread = (thread_t*)arg;