got all of the code to actually compile again
I don't think it actually works though.
diff --git a/aos/common/condition.h b/aos/common/condition.h
index c527f34..956dc6c 100644
--- a/aos/common/condition.h
+++ b/aos/common/condition.h
@@ -1,60 +1,41 @@
#ifndef AOS_COMMON_CONDITION_H_
#define AOS_COMMON_CONDITION_H_
-#ifdef __VXWORKS__
-#include <semLib.h>
-#endif
-
-#include "aos/aos_core.h"
#include "aos/common/mutex.h"
+#include "aos/atom_code/ipc_lib/aos_sync.h"
namespace aos {
// A condition variable (IPC mechanism where 1 process/task can notify all
// others that are waiting for something to happen).
-// There are implementations for both the atom and the cRIO.
-// They both LOG(FATAL) if anything weird happens.
+// This implementation will LOG(FATAL) if anything weird happens.
//
-// A condition is either set or unset, and multiple processes/tasks can wait on
-// one for it to be set.
+// Multiple condition variables may be associated with the same mutex but
+// exactly 1 mutex must be associated with each condition variable.
class Condition {
public:
- // Creates an unset condition.
- Condition();
-#ifdef __VXWORKS__
- // Will not make sure that it is either set or unset.
- ~Condition();
-#endif
- // Waits for the condition to be set. Will return true immediately if it is
- // already set.
- // Returns false if returning before a confirmed condition set, although doing
- // anything very useful with the return value is difficult because the
- // condition may have been set (and possibly even unset again) between the
- // time when the system call to block returned and this function returns.
- bool Wait();
- // Waits for the next Set(), regardless of whether or not the condition is
- // currently set.
- // Same return value as Wait().
- bool WaitNext();
+ // m is the mutex that will be associated with this condition variable.
+ explicit Condition(Mutex *m);
- // Sets the condition. Any processes/tasks that are currently Wait()ing will
- // continue.
- // All implementations will wake all waiting processes/tasks at once so that
- // the highest priority one(s) will run before others like usual.
- void Set();
- // Unsets the condition.
- void Unset();
+ // Waits for the condition variable to be signalled, atomically unlocking m at
+ // the same time. The mutex associated with this condition variable must be
+ // locked when this is called and will be locked when this method returns.
+ void Wait();
+
+ // Signals at most 1 other process currently Wait()ing on this condition
+ // variable. Calling this does not require the mutex associated with this
+ // condition variable to be locked.
+ // One of the processes with the highest priority level will be woken if there
+ // are multiple ones.
+ void Signal();
+ // Wakes all processes that are currently Wait()ing on this condition
+ // variable. Calling this does not require the mutex associated with this
+ // condition variable to be locked.
+ void Broadcast();
private:
-#ifdef __VXWORKS__
- // Always empty. Used to make tasks wait and then gets flushed to unblock all
- // of them.
- SEM_ID wait_;
- // Whether or not the conditon is set.
- bool set_;
-#else
- mutex impl_;
-#endif
+ condition_variable impl_;
+ Mutex *m_;
};
} // namespace aos