Merge lp:~mhr3/unity/ubus-rewrite into lp:unity
| Status: | Merged |
|---|---|
| Approved by: | Gord Allott on 2012-10-15 |
| Approved revision: | 2776 |
| Merged at revision: | 2838 |
| Proposed branch: | lp:~mhr3/unity/ubus-rewrite |
| Merge into: | lp:unity |
| Diff against target: |
1805 lines (+624/-745) 28 files modified
UnityCore/Variant.cpp (+13/-1) UnityCore/Variant.h (+2/-0) dash/DashController.cpp (+4/-3) dash/DashController.h (+1/-0) dash/DashView.cpp (+2/-1) dash/PlacesGroup.cpp (+1/-1) dash/ResultViewGrid.cpp (+1/-1) launcher/ApplicationLauncherIcon.cpp (+0/-1) launcher/LauncherController.cpp (+2/-1) launcher/LauncherIcon.cpp (+2/-3) launcher/QuicklistManager.cpp (+2/-3) launcher/QuicklistView.cpp (+3/-7) launcher/SimpleLauncherIcon.cpp (+2/-3) launcher/Tooltip.cpp (+2/-3) plugins/unityshell/src/UnityGestureTarget.cpp (+2/-4) plugins/unityshell/src/unity-root-accessible.cpp (+3/-1) plugins/unityshell/src/unityshell.cpp (+1/-0) tests/CMakeLists.txt (+4/-3) tests/test_ubus.cpp (+327/-0) tests/unit/TestMain.cpp (+0/-2) tests/unit/TestUBus.cpp (+0/-157) unity-shared/CMakeLists.txt (+1/-1) unity-shared/UBusServer.cpp (+120/-0) unity-shared/UBusServer.h (+71/-0) unity-shared/UBusWrapper.cpp (+42/-49) unity-shared/UBusWrapper.h (+16/-23) unity-shared/ubus-server.cpp (+0/-397) unity-shared/ubus-server.h (+0/-80) |
| To merge this branch: | bzr merge lp:~mhr3/unity/ubus-rewrite |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Marco Trevisan (Treviño) | Approve on 2012-10-12 | ||
| Andrea Azzarone | 2012-10-03 | Approve on 2012-10-12 | |
| jenkins | continuous-integration | Pending | |
|
Review via email:
|
|||
Commit Message
Rewrite UBus
Description of the Change
Remove last bit of good old GObject code and replace it with C++ version of UBus, the only additional feature atm is the ability to specify priority when sending UBus messages. Besides that change the API stayed pretty much the same (with the exception of using glib::Variant instead of raw GVariant*).
The default priority of messages was also bumped to DEFAULT (instead of DEFAULT_IDLE), to try to prevent issues like lp:1064256 (arguably it might be good idea to lower the prio once unity isn't running in the same thread as compiz, but for now this will be better default).
| Brandon Schaefer (brandontschaefer) wrote : | # |
| Andrea Azzarone (azzar1) wrote : | # |
966 +UBusServer:
967 +{
968 +}
Remove it please. It should not be required.
5 + for (auto it = interests_.begin(); it != interests_.end(); ++it)
986 + {
987 + if ((*it).second->id == connection_id)
988 + {
989 + interests_
990 + return;
991 + }
992 + }
Can you use the range-based for loop of std::erase + std::remove_if?
995 +void UBusServer:
996 + glib::Variant const& args)
997 +{
998 + SendMessageFull
999 +}
1000 +
1001 +void UBusServer:
1002 + glib::Variant const& args,
1003 + glib::Source:
1004 +{
What about default value here?
+ msg_queue_
ouch :) std::make_pair will make this line shorter :)
1009 + auto src_nick = boost::
std::to_string should be good :)
1088 +#include <vector>
1089 +#include <boost/utility.hpp>
I think these are not needed.
1221 + // we don't want to modify a container while iterating it
1222 + std::set<unsigned> ids_copy(
1223 + for (auto it = ids_copy.begin(); it != ids_copy.end(); ++it)
1224 + {
1225 + UnregisterInter
1226 + }
IIRC std::set::erase does not invalidate all the iterators of the container, but just the iterator of the erased element. So you can avoid std::set<unsigned> ids_copy(
for (...) {
auto to_delete = it;
it++; // don't do this above too :)
UnregisterInt
}
But i'm not really sure about this :)
1274 +#include <map>
Should not be necessary.
| Marco Trevisan (Treviño) (3v1n0) wrote : | # |
1006 + msg_queue_
It can be just std::make_
1009 + auto src_nick = boost::
No need for it with C++11, just use std::to_
985 + for (auto it = interests_.begin(); it != interests_.end(); ++it)
Not tried, but I guess that also the multimaps, would handle nicely a for (auto const& : interests_) foreach loop.
983 +void UBusServer:
I know this is safer, but what's the reason why not to add also UBusServer:
[NVM, I've noticed that now there's only just one static UBusServer: +1].
1034 + for (unsigned i = 0; i < dispatched_
Use ++i or just a foreach loop.
1221 + // we don't want to modify a container while iterating it
1222 + std::set<unsigned> ids_copy(
1223 + for (auto it = ids_copy.begin(); it != ids_copy.end(); ++it)
1224 + {
1225 + UnregisterInter
1226 + }
this is also safe:
for (auto it = ids_copy.begin(); it != ids_copy.end();)
{
UnregisterInt
}
1317 + static std::unique_
You can just use an stack allocated server here, just remember to add this to the .cpp file:
// initialize the global static server
UBusServer UBusManager:
PS: add yourself to to authors, so people will bother you when on troubles ;-D
- 2775. By Michal Hruby on 2012-10-12
-
Fix issues brought up during review
| Michal Hruby (mhr3) wrote : | # |
> Remove it please. It should not be required.
Done
> Can you use the range-based for loop of std::erase + std::remove_if?
remove_if traverses the entire collection, I know there's just one item with the given id, so used find_if + erase instead.
> What about default value here?
It's *Full because the default param-variant is SendMessage().
> ouch :) std::make_pair will make this line shorter :)
Fixed.
> std::to_string should be good :)
Fixed.
> I think these are not needed.
Removed.
> IIRC std::set::erase does not invalidate all the iterators of the container,
> but just the iterator of the erased element. So you can avoid
> std::set<unsigned> ids_copy(
> ...
The Unregister calls can lead to more Unregister calls (destroying a signal handler can lead to destruction of another object that will call Unregister in its own destructor), it's safer to try to call Unregister with already unregistered id, than to use invalid iterator.
>
> 1274 +#include <map>
>
> Should not be necessary.
Removed.
| Michal Hruby (mhr3) wrote : | # |
> 1034 + for (unsigned i = 0; i < dispatched_
>
> Use ++i or just a foreach loop.
It's 2012, compilers do that these days ;) (plus it's simple type, so there's no ambiguity)
>
> 1221 + // we don't want to modify a container while iterating it
> 1222 + std::set<unsigned> ids_copy(
> 1223 + for (auto it = ids_copy.begin(); it != ids_copy.end(); ++it)
> 1224 + {
> 1225 + UnregisterInter
> 1226 + }
>
> this is also safe:
> for (auto it = ids_copy.begin(); it != ids_copy.end();)
> {
> UnregisterInter
> }
True, but it looks weird :P
>
> 1317 + static std::unique_
>
> You can just use an stack allocated server here, just remember to add this to
> the .cpp file:
> // initialize the global static server
> UBusServer UBusManager:
I'd rather keep it this way, it allows lazy initialization (even though not used now).
> PS: add yourself to to authors, so people will bother you when on troubles ;-D
Done.
- 2776. By Michal Hruby on 2012-10-12
-
Update authors
| Andrea Azzarone (azzar1) wrote : | # |
> 966 +UBusServer:
> 967 +{
> 968 +}
>
> Remove it please. It should not be required.
>
> 5 + for (auto it = interests_.begin(); it != interests_.end(); ++it)
> 986 + {
> 987 + if ((*it).second->id == connection_id)
> 988 + {
> 989 + interests_
> 990 + return;
> 991 + }
> 992 + }
>
> Can you use the range-based for loop of std::erase + std::remove_if?
>
> 995 +void UBusServer:
> 996 + glib::Variant const& args)
> 997 +{
> 998 + SendMessageFull
> glib::Source:
> 999 +}
> 1000 +
> 1001 +void UBusServer:
> 1002 + glib::Variant const& args,
> 1003 + glib::Source:
> 1004 +{
I mean you ca do:
class UbusServer {
...
void SendMessage(
...
}
So you don't need two functions. But this is not blocking.
>
> What about default value here?
>
> + msg_queue_
> glib::Variant>
> args)));
>
> ouch :) std::make_pair will make this line shorter :)
>
> 1009 + auto src_nick =
> boost::
>
> std::to_string should be good :)
>
> 1088 +#include <vector>
> 1089 +#include <boost/utility.hpp>
>
> I think these are not needed.
>
> 1221 + // we don't want to modify a container while iterating it
> 1222 + std::set<unsigned> ids_copy(
> 1223 + for (auto it = ids_copy.begin(); it != ids_copy.end(); ++it)
> 1224 + {
> 1225 + UnregisterInter
> 1226 + }
>
> IIRC std::set::erase does not invalidate all the iterators of the container,
> but just the iterator of the erased element. So you can avoid
> std::set<unsigned> ids_copy(
>
> for (...) {
> auto to_delete = it;
> it++; // don't do this above too :)
> UnregisterInter
> }
>
> But i'm not really sure about this :)
>
> 1274 +#include <map>
>
> Should not be necessary.
| Michal Hruby (mhr3) wrote : | # |
> void SendMessage(
> args, glib::Source:
> ...
> }
>
> So you don't need two functions. But this is not blocking.
Right, fwiw UBusManager is doing that, and noone should be using the server directly.


Overall it looks good. I haven't had the time to do much testing, but I tried to fix that launcher showing to slowly and there seems to be another bug located in that...
Ill spend some more time running tests and playing around with this some more :)
Thanks!