From e74a06d22d48ee4903ec933f4332b261d633514b Mon Sep 17 00:00:00 2001 From: Konrad Lipinski Date: Tue, 24 Sep 2019 14:58:06 +0200 Subject: [PATCH] Devirtualize DescriptorSet Change-Id: I985ab5279078ffde6686390a1d3284a3e93ff92d --- src/manager/client-async/descriptor-set.h | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/manager/client-async/descriptor-set.h b/src/manager/client-async/descriptor-set.h index 931d10d..de8e24b 100644 --- a/src/manager/client-async/descriptor-set.h +++ b/src/manager/client-async/descriptor-set.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2000-2019 Samsung Electronics Co., Ltd. All rights reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,8 +34,8 @@ public: // int is for descriptor, short is for revents, typedef std::function Callback; - virtual void add(int fd, short events, Callback &&callback) = 0; - virtual void remove(int fd, bool close_fd = true) = 0; + void add(int fd, short events, Callback &&callback); + void remove(int fd, bool close_fd = true); protected: // I don't want anyone to manage object lifetime via interface. IDescriptorSet() {} @@ -45,10 +45,10 @@ protected: /** * @brief Wrapper for poll() */ -class DescriptorSet : public IDescriptorSet { +class DescriptorSet final : public IDescriptorSet { public: DescriptorSet(); - virtual ~DescriptorSet(); + ~DescriptorSet(); NONCOPYABLE(DescriptorSet); @@ -61,19 +61,19 @@ public: * @param events events to watch for * @param callback callback to be called when an event on descriptor occurs */ - virtual void add(int fd, short events, Callback &&callback); + void add(int fd, short events, Callback &&callback); /* * Removes give descriptor from watched set and closes it. * * @param fd descriptor to be removed and closed */ - virtual void remove(int fd, bool close_fd = true); + void remove(int fd, bool close_fd = true); /* * Wait for descriptor events using poll(). * Synchronously calls provided descriptor callbacks. * - * @param timeout_ms timeout in ms. egative value means no timeout. + * @param timeout_ms timeout in ms. negative value means no timeout. * * @throws Timeout exception in case of timeout * @throws InternalError in case of other error @@ -87,7 +87,7 @@ public: DECLARE_EXCEPTION_TYPE(CKM::Exception, InternalError); DECLARE_EXCEPTION_TYPE(CKM::Exception, Timeout); -protected: +private: // returns false if there are no descriptors to wait for bool rebuildPollfd(); void notify(int descCount); @@ -106,4 +106,11 @@ protected: pollfd *m_fds; }; +inline void IDescriptorSet::add(int fd, short events, Callback &&callback) { + static_cast(this)->add(fd, events, std::move(callback)); +} +inline void IDescriptorSet::remove(int fd, bool close_fd) { + static_cast(this)->remove(fd, close_fd); +} + } /* namespace CKM */ -- 2.7.4