1 /* Copyright 2017-2021 PaGMO development team
2 
3 This file is part of the PaGMO library.
4 
5 The PaGMO library is free software; you can redistribute it and/or modify
6 it under the terms of either:
7 
8   * the GNU Lesser General Public License as published by the Free
9     Software Foundation; either version 3 of the License, or (at your
10     option) any later version.
11 
12 or
13 
14   * the GNU General Public License as published by the Free Software
15     Foundation; either version 3 of the License, or (at your option) any
16     later version.
17 
18 or both in parallel, as here.
19 
20 The PaGMO library is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
22 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23 for more details.
24 
25 You should have received copies of the GNU General Public License and the
26 GNU Lesser General Public License along with the PaGMO library.  If not,
27 see https://www.gnu.org/licenses/. */
28 
29 #ifndef PAGMO_ISLANDS_THREAD_ISLAND_HPP
30 #define PAGMO_ISLANDS_THREAD_ISLAND_HPP
31 
32 #include <string>
33 
34 #include <pagmo/detail/visibility.hpp>
35 #include <pagmo/island.hpp>
36 #include <pagmo/s11n.hpp>
37 
38 namespace pagmo
39 {
40 
41 // Thread island.
42 class PAGMO_DLL_PUBLIC thread_island
43 {
44 public:
45     // Default ctor.
46     thread_island();
47     // Ctor with use_pool flag.
48     explicit thread_island(bool);
49 
50     // Island's name.
51     std::string get_name() const;
52     // Extra info.
53     std::string get_extra_info() const;
54 
55     // run_evolve implementation.
56     void run_evolve(island &) const;
57 
58 private:
59     // Object serialization
60     friend class boost::serialization::access;
61     template <typename Archive>
62     void save(Archive &, unsigned) const;
63     template <typename Archive>
64     void load(Archive &, unsigned);
65     BOOST_SERIALIZATION_SPLIT_MEMBER()
66 
67     bool m_use_pool;
68 };
69 
70 } // namespace pagmo
71 
72 PAGMO_S11N_ISLAND_EXPORT_KEY(pagmo::thread_island)
73 
74 // NOTE: version 1 added the m_use_pool flag.
75 BOOST_CLASS_VERSION(pagmo::thread_island, 1)
76 
77 #endif
78