From a5c50a4f262f0a880734623f79d4dc2f1aa8a0a2 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Tue, 13 Aug 2019 10:29:39 +0200 Subject: Pull in files from odr-mmbtools-common Replace ASIO by simpler implementation, meaning that the telnet RC now only supports a single connection. Move Log, RC to lib/ --- lib/asio/detail/object_pool.hpp | 171 ---------------------------------------- 1 file changed, 171 deletions(-) delete mode 100644 lib/asio/detail/object_pool.hpp (limited to 'lib/asio/detail/object_pool.hpp') diff --git a/lib/asio/detail/object_pool.hpp b/lib/asio/detail/object_pool.hpp deleted file mode 100644 index e1a3c54..0000000 --- a/lib/asio/detail/object_pool.hpp +++ /dev/null @@ -1,171 +0,0 @@ -// -// detail/object_pool.hpp -// ~~~~~~~~~~~~~~~~~~~~~~ -// -// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef ASIO_DETAIL_OBJECT_POOL_HPP -#define ASIO_DETAIL_OBJECT_POOL_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "asio/detail/noncopyable.hpp" - -#include "asio/detail/push_options.hpp" - -namespace asio { -namespace detail { - -template -class object_pool; - -class object_pool_access -{ -public: - template - static Object* create() - { - return new Object; - } - - template - static Object* create(Arg arg) - { - return new Object(arg); - } - - template - static void destroy(Object* o) - { - delete o; - } - - template - static Object*& next(Object* o) - { - return o->next_; - } - - template - static Object*& prev(Object* o) - { - return o->prev_; - } -}; - -template -class object_pool - : private noncopyable -{ -public: - // Constructor. - object_pool() - : live_list_(0), - free_list_(0) - { - } - - // Destructor destroys all objects. - ~object_pool() - { - destroy_list(live_list_); - destroy_list(free_list_); - } - - // Get the object at the start of the live list. - Object* first() - { - return live_list_; - } - - // Allocate a new object. - Object* alloc() - { - Object* o = free_list_; - if (o) - free_list_ = object_pool_access::next(free_list_); - else - o = object_pool_access::create(); - - object_pool_access::next(o) = live_list_; - object_pool_access::prev(o) = 0; - if (live_list_) - object_pool_access::prev(live_list_) = o; - live_list_ = o; - - return o; - } - - // Allocate a new object with an argument. - template - Object* alloc(Arg arg) - { - Object* o = free_list_; - if (o) - free_list_ = object_pool_access::next(free_list_); - else - o = object_pool_access::create(arg); - - object_pool_access::next(o) = live_list_; - object_pool_access::prev(o) = 0; - if (live_list_) - object_pool_access::prev(live_list_) = o; - live_list_ = o; - - return o; - } - - // Free an object. Moves it to the free list. No destructors are run. - void free(Object* o) - { - if (live_list_ == o) - live_list_ = object_pool_access::next(o); - - if (object_pool_access::prev(o)) - { - object_pool_access::next(object_pool_access::prev(o)) - = object_pool_access::next(o); - } - - if (object_pool_access::next(o)) - { - object_pool_access::prev(object_pool_access::next(o)) - = object_pool_access::prev(o); - } - - object_pool_access::next(o) = free_list_; - object_pool_access::prev(o) = 0; - free_list_ = o; - } - -private: - // Helper function to destroy all elements in a list. - void destroy_list(Object* list) - { - while (list) - { - Object* o = list; - list = object_pool_access::next(o); - object_pool_access::destroy(o); - } - } - - // The list of live objects. - Object* live_list_; - - // The free list. - Object* free_list_; -}; - -} // namespace detail -} // namespace asio - -#include "asio/detail/pop_options.hpp" - -#endif // ASIO_DETAIL_OBJECT_POOL_HPP -- cgit v1.2.3