diff options
author | Philip Rauwolf <rauwolf@itestra.de> | 2013-08-07 14:54:45 +0200 |
---|---|---|
committer | Stefan Laner <laner@itestra.de> | 2013-08-07 15:08:33 +0200 |
commit | 9f66fbe2099558c08b2f10c03262c4ad220f0ec3 (patch) | |
tree | 56c3ecc736cc1d6bd9eda892d7881223621afc91 /src | |
parent | d5c7906b728d6a03c468d9c4211417f97702494a (diff) | |
download | genivi-common-api-dbus-runtime-9f66fbe2099558c08b2f10c03262c4ad220f0ec3.tar.gz |
Fixed Demo Mainloop
Conflicts:
src/test/DemoMainLoop.h
Diffstat (limited to 'src')
-rw-r--r-- | src/test/DBusProxyTest.cpp | 8 | ||||
-rw-r--r-- | src/test/DemoMainLoop.h | 32 |
2 files changed, 23 insertions, 17 deletions
diff --git a/src/test/DBusProxyTest.cpp b/src/test/DBusProxyTest.cpp index a45f6f2..3fc2c23 100644 --- a/src/test/DBusProxyTest.cpp +++ b/src/test/DBusProxyTest.cpp @@ -8,6 +8,10 @@ #define _GLIBCXX_USE_NANOSLEEP #endif +#ifndef COMMONAPI_INTERNAL_COMPILATION +#define COMMONAPI_INTERNAL_COMPILATION +#endif + #include <CommonAPI/DBus/DBusInputStream.h> #include <CommonAPI/DBus/DBusMessage.h> #include <CommonAPI/DBus/DBusProxy.h> @@ -18,6 +22,10 @@ #include <commonapi/tests/TestInterfaceDBusStubAdapter.h> #include <commonapi/tests/TestInterfaceStubDefault.h> +#ifndef COMMONAPI_INTERNAL_COMPILATION +#define COMMONAPI_INTERNAL_COMPILATION +#endif + #include "DBusTestUtils.h" #include <gtest/gtest.h> diff --git a/src/test/DemoMainLoop.h b/src/test/DemoMainLoop.h index 4cbf47a..335c102 100644 --- a/src/test/DemoMainLoop.h +++ b/src/test/DemoMainLoop.h @@ -9,7 +9,11 @@ #define DEMO_MAIN_LOOP_H_ +#if !defined (COMMONAPI_INTERNAL_COMPILATION) +#define COMMONAPI_INTERNAL_COMPILATION +#endif #include <CommonAPI/MainLoopContext.h> +#undef COMMONAPI_INTERNAL_COMPILATION #include <vector> #include <set> @@ -63,7 +67,10 @@ class MainLoop { } /** - * The given timeout will be overridden if a timeout-event is present that defines an earlier ready time. + * \brief Runs the mainloop indefinitely until stop() is called. + * + * Runs the mainloop indefinitely until stop() is called. The given timeout (milliseconds) + * will be overridden if a timeout-event is present that defines an earlier ready time. */ void run(const int64_t& timeoutInterval = TIMEOUT_INFINITE) { running_ = true; @@ -142,7 +149,7 @@ class MainLoop { (*fileDescriptor).revents = 0; } - auto numReadyFileDescriptors = ::poll(&(managedFileDescriptors_[0]), managedFileDescriptors_.size(), currentMinimalTimeoutInterval_); + size_t numReadyFileDescriptors = ::poll(&(managedFileDescriptors_[0]), managedFileDescriptors_.size(), currentMinimalTimeoutInterval_); // If no FileDescriptors are ready, poll returned because of a timeout that has expired. // The only case in which this is not the reason is when the timeout handed in "prepare" @@ -170,14 +177,14 @@ class MainLoop { bool check() { //The first file descriptor always is the loop's wakeup-descriptor. All others need to be linked to a watch. for (auto fileDescriptor = managedFileDescriptors_.begin() + 1; fileDescriptor != managedFileDescriptors_.end(); ++fileDescriptor) { - for(auto registeredWatchIterator = registeredWatches_.begin(); + for (auto registeredWatchIterator = registeredWatches_.begin(); registeredWatchIterator != registeredWatches_.end(); registeredWatchIterator++) { const auto& correspondingWatchPriority = registeredWatchIterator->first; const auto& correspondingWatchPair = registeredWatchIterator->second; if (std::get<0>(correspondingWatchPair) == fileDescriptor->fd && fileDescriptor->revents) { - watchesToDispatch_.insert( { correspondingWatchPriority, {std::get<1>(correspondingWatchPair), fileDescriptor->revents} } ); + watchesToDispatch_.insert( { correspondingWatchPriority, {std::get<1>(correspondingWatchPair)} } ); } } } @@ -201,18 +208,9 @@ class MainLoop { for (auto watchIterator = watchesToDispatch_.begin(); watchIterator != watchesToDispatch_.end(); watchIterator++) { - Watch* watch = std::get<0>(watchIterator->second); - const unsigned int flags = std::get<1>(watchIterator->second); - const auto& dependentSources = watch->getDependentDispatchSources(); + Watch* watch = watchIterator->second; + const unsigned int flags = 7; watch->dispatch(flags); - - for (auto dependentSourceIterator = dependentSources.begin(); - dependentSourceIterator != dependentSources.end(); - dependentSourceIterator++) { - if((*dependentSourceIterator)->check()) { - sourcesToDispatch_.insert( {watchIterator->first, *dependentSourceIterator} ); - } - } } breakLoop_ = false; @@ -276,7 +274,7 @@ class MainLoop { watchIterator != registeredWatches_.end(); watchIterator++) { - if(watchIterator->second.first == watch->getAssociatedFileDescriptor().fd) { + if(watchIterator->second.second == watch) { registeredWatches_.erase(watchIterator); break; } @@ -313,7 +311,7 @@ class MainLoop { std::multimap<DispatchPriority, Timeout*> registeredTimeouts_; std::set<std::pair<DispatchPriority, DispatchSource*>> sourcesToDispatch_; - std::set<std::pair<DispatchPriority, std::pair<Watch*, unsigned short>>> watchesToDispatch_; + std::set<std::pair<DispatchPriority, Watch*>> watchesToDispatch_; std::set<std::pair<DispatchPriority, Timeout*>> timeoutsToDispatch_; DispatchSourceListenerSubscription dispatchSourceListenerSubscription_; |