25 #ifndef WCONDITIONSET_TEST_H
26 #define WCONDITIONSET_TEST_H
31 #include <boost/thread.hpp>
32 #include <cxxtest/TestSuite.h>
34 #include "../WCondition.h"
35 #include "../WConditionSet.h"
61 boost::this_thread::sleep( boost::posix_time::seconds( 1 ) );
80 TS_ASSERT_THROWS_NOTHING(
delete c );
91 std::shared_ptr< WCondition > c1(
new WCondition() );
92 std::shared_ptr< WCondition > c2(
new WCondition() );
93 std::shared_ptr< WCondition > c3(
new WCondition() );
96 TS_ASSERT_THROWS_NOTHING( cs->
add( c1 ) );
98 TS_ASSERT_THROWS_NOTHING( cs->
add( c1 ) );
99 TS_ASSERT_THROWS_NOTHING( cs->
add( c2 ) );
105 TS_ASSERT_THROWS_NOTHING( cs->
remove( c3 ) );
109 TS_ASSERT_THROWS_NOTHING( cs->
remove( c1 ) );
113 TS_ASSERT_THROWS_NOTHING( cs->
remove( c2 ) );
127 std::shared_ptr< WCondition > c1(
new WCondition() );
128 std::shared_ptr< WCondition > c2(
new WCondition() );
173 std::shared_ptr< WCondition > c1(
new WCondition() );
174 std::shared_ptr< WCondition > c2(
new WCondition() );
221 TS_ASSERT_THROWS_NOTHING( cs->
reset() );
void threadMain()
Thread main method.
WCondition * c
The condition to be used for signalling.
bool flag
Flag set to true when thread starts.
void testInstantiation(void)
An instantiation should never throw an exception, as well as tear down.
void testWaitResetable(void)
Tests the resetable feature.
void testResetOnNotResetable(void)
Ensures reset() never throws something.
void testAddRemove(void)
Tests add and remove methods.
void testWait(void)
Tests whether the condition set really reacts on fired conditions.
Class allowing multiple conditions to be used for one waiting cycle.
virtual void wait() const
Wait for the condition.
ConditionConnectionMap m_conditionSet
Set of conditions to be waited for.
bool m_fired
Flag denoting whether one condition fired in the past.
virtual void reset() const
Resets the internal fire state.
void setResetable(bool resetable=true, bool autoReset=true)
Sets the resetable flag.
virtual void remove(std::shared_ptr< WCondition > condition)
Removes the specified condition.
virtual void add(std::shared_ptr< WCondition > condition)
Adds another condition to the set of conditions to wait for.
Class to encapsulate boost::condition_variable_any.
virtual void notify()
Notifies all waiting threads.