Teach ShmEventLoop how to validate some multithreading use cases

This helps catch bugs in callers who do these limited kinds of
multithreading.

Change-Id: Ie04790b2c46f0401430ed4c18a2d10845329623b
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/aos/stl_mutex/stl_mutex.h b/aos/stl_mutex/stl_mutex.h
index 86a5988..e3a930e 100644
--- a/aos/stl_mutex/stl_mutex.h
+++ b/aos/stl_mutex/stl_mutex.h
@@ -61,6 +61,11 @@
   bool owner_died() const { return owner_died_; }
   void consistent() { owner_died_ = false; }
 
+  // Returns whether this mutex is locked by the current thread. This is very
+  // hard to use reliably, please think very carefully before using it for
+  // anything beyond probabilistic assertion checks.
+  bool is_locked() const { return mutex_islocked(&native_handle_); }
+
  private:
   aos_mutex native_handle_;
 
@@ -82,7 +87,7 @@
   constexpr stl_recursive_mutex() {}
 
   void lock() {
-    if (mutex_islocked(mutex_.native_handle())) {
+    if (mutex_.is_locked()) {
       CHECK(!owner_died());
       ++recursive_locks_;
     } else {
@@ -95,7 +100,7 @@
     }
   }
   bool try_lock() {
-    if (mutex_islocked(mutex_.native_handle())) {
+    if (mutex_.is_locked()) {
       CHECK(!owner_died());
       ++recursive_locks_;
       return true;