Repository: mesos Updated Branches: refs/heads/master 34543c768 -> d7c0873e7
Convert Non-POD static variables in fq_codel and ingress to constexpr. Review: https://reviews.apache.org/r/34782 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d7c0873e Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d7c0873e Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d7c0873e Branch: refs/heads/master Commit: d7c0873e726eec41fff3dbc95cce0bdce112ffc5 Parents: 34543c7 Author: Paul Brett <[email protected]> Authored: Fri May 29 14:21:38 2015 -0700 Committer: Vinod Kone <[email protected]> Committed: Fri May 29 14:21:38 2015 -0700 ---------------------------------------------------------------------- src/linux/routing/handle.hpp | 24 ++++++++++-------------- src/linux/routing/queueing/fq_codel.cpp | 6 ------ src/linux/routing/queueing/fq_codel.hpp | 8 ++++++-- src/linux/routing/queueing/ingress.cpp | 3 --- src/linux/routing/queueing/ingress.hpp | 4 ++-- 5 files changed, 18 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/d7c0873e/src/linux/routing/handle.hpp ---------------------------------------------------------------------- diff --git a/src/linux/routing/handle.hpp b/src/linux/routing/handle.hpp index 8f2da06..4ce1588 100644 --- a/src/linux/routing/handle.hpp +++ b/src/linux/routing/handle.hpp @@ -36,34 +36,30 @@ namespace routing { class Handle { public: - explicit Handle(uint32_t _handle) : handle(_handle) {} + explicit constexpr Handle(uint32_t _handle) : handle(_handle) {} - Handle(uint16_t primary, uint16_t secondary) - { - handle = (((uint32_t)primary) << 16) + secondary; - } + constexpr Handle(uint16_t primary, uint16_t secondary) : + handle((((uint32_t)primary) << 16) + secondary) {} // NOTE: This is used to construct a classid. The higher 16 bits of // the given 'parent' will be the primary and the lower 16 bits is // specified by the given 'id'. - Handle(Handle parent, uint16_t id) - { - handle = (((uint32_t)parent.primary()) << 16) + id; - } + constexpr Handle(const Handle& parent, uint16_t id) : + handle((((uint32_t)parent.primary()) << 16) + id) {} - bool operator==(const Handle& that) const + constexpr bool operator==(const Handle& that) const { return handle == that.handle; } - bool operator!=(const Handle& that) const + constexpr bool operator!=(const Handle& that) const { return handle != that.handle; } - uint16_t primary() const { return handle >> 16; } - uint16_t secondary() const { return handle & 0x0000ffff; } - uint32_t get() const { return handle; } + constexpr uint16_t primary() const { return handle >> 16; } + constexpr uint16_t secondary() const { return handle & 0x0000ffff; } + constexpr uint32_t get() const { return handle; } protected: uint32_t handle; http://git-wip-us.apache.org/repos/asf/mesos/blob/d7c0873e/src/linux/routing/queueing/fq_codel.cpp ---------------------------------------------------------------------- diff --git a/src/linux/routing/queueing/fq_codel.cpp b/src/linux/routing/queueing/fq_codel.cpp index f9db58b..64b5c73 100644 --- a/src/linux/routing/queueing/fq_codel.cpp +++ b/src/linux/routing/queueing/fq_codel.cpp @@ -111,12 +111,6 @@ Result<fq_codel::Discipline> decode<fq_codel::Discipline>( namespace fq_codel { -// NOTE: Root queueing discipline handle has to be X:0, so handle's -// secondary number has to be 0 here. There can be only one root -// queueing discipline on the egress side of a link. -const Handle HANDLE = Handle(0x1, 0); - - const int DEFAULT_FLOWS = 1024; http://git-wip-us.apache.org/repos/asf/mesos/blob/d7c0873e/src/linux/routing/queueing/fq_codel.hpp ---------------------------------------------------------------------- diff --git a/src/linux/routing/queueing/fq_codel.hpp b/src/linux/routing/queueing/fq_codel.hpp index 0248616..7de1e31 100644 --- a/src/linux/routing/queueing/fq_codel.hpp +++ b/src/linux/routing/queueing/fq_codel.hpp @@ -29,8 +29,12 @@ namespace routing { namespace queueing { namespace fq_codel { -// The handle of the fq_codel queueing discipline is fixed. -extern const Handle HANDLE; +// NOTE: Root queueing discipline handle has to be X:0, so handle's +// secondary number has to be 0 here. There can be only one root +// queueing discipline on the egress side of a link and fq_codel is +// classless and hence there is only one instance of fq_codel per +// link. This allows us to fix the fq_codel handle. +constexpr Handle HANDLE(1, 0); // The default number of flows for the fq_codel queueing discipline. http://git-wip-us.apache.org/repos/asf/mesos/blob/d7c0873e/src/linux/routing/queueing/ingress.cpp ---------------------------------------------------------------------- diff --git a/src/linux/routing/queueing/ingress.cpp b/src/linux/routing/queueing/ingress.cpp index fece104..ae0c38d 100644 --- a/src/linux/routing/queueing/ingress.cpp +++ b/src/linux/routing/queueing/ingress.cpp @@ -38,9 +38,6 @@ namespace queueing { namespace ingress { -const Handle ROOT = Handle(TC_H_INGRESS); -const Handle HANDLE = Handle(0xffff, 0); - // The ingress queueing discipline is not exposed to the user. struct Discipline { http://git-wip-us.apache.org/repos/asf/mesos/blob/d7c0873e/src/linux/routing/queueing/ingress.hpp ---------------------------------------------------------------------- diff --git a/src/linux/routing/queueing/ingress.hpp b/src/linux/routing/queueing/ingress.hpp index 4c96b60..84506fe 100644 --- a/src/linux/routing/queueing/ingress.hpp +++ b/src/linux/routing/queueing/ingress.hpp @@ -48,8 +48,8 @@ namespace ingress { // for the interface which specify the root handle under which a // queueing discipline can be created, and the handle of any created // ingress filter. -extern const Handle ROOT; -extern const Handle HANDLE; +constexpr Handle ROOT(Handle(TC_H_INGRESS)); +constexpr Handle HANDLE(Handle(0xffff, 0)); // Returns true if there exists an ingress qdisc on the link.
