D.S

dev.mysql.com

MySQL: client/dump/object_queue.h Source File

MySQL: client/dump/object_queue.h Source File MySQL  8.0.0 Source Code Documentation Main Page Related Pages Modules Namespaces Classes Files File List File Members object_queue.h Go to the documentation of this file. 1 /* 2  Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. 3  4  This program is free software; you can redistribute it and/or modify 5  it under the terms of the GNU General Public License as published by 6  the Free Software Foundation; version 2 of the License. 7  8  This program is distributed in the hope that it will be useful, 9  but WITHOUT ANY WARRANTY; without even the implied warranty of 10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11  GNU General Public License for more details. 12  13  You should have received a copy of the GNU General Public License 14  along with this program; if not, write to the Free Software 15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 16 */ 17  18 #ifndef OBJECT_QUEUE_INCLUDED 19 #define OBJECT_QUEUE_INCLUDED 20  21 #include " i_object_reader.h " 22 #include " abstract_object_reader_wrapper.h " 23 #include " abstract_dump_task.h " 24 #include " base/abstract_program.h " 25 #include " thread_group.h " 26 #include " base/mutex.h " 27 #include " base/atomic.h " 28 #include <map> 29 #include <queue> 30  31 namespace Mysql { 32 namespace Tools{ 33 namespace Dump{ 34  35 /** 36  Wrapper to another Object Reader, adds all objects to read on queue. Allows 37  specified number of threads to dequeue and process objects. 38  */ 39  class Object_queue : public Abstract_object_reader_wrapper , 40  public I_object_reader 41 { 42 public: 43  Object_queue ( 44  Mysql::I_callable<bool, const Mysql::Tools::Base::Message_data&> * 45  message_handler, Simple_id_generator * object_id_generator, 46  uint threads_count, Mysql::I_callable<void, bool> * thread_callback, 47  Mysql::Tools::Base::Abstract_program * program ); 48  49  ~Object_queue (); 50  51  void read_object ( Item_processing_data * item_to_process); 52  53  // Fix "inherits ... via dominance" warnings 54   void register_progress_watcher ( I_progress_watcher * new_progress_watcher) 55  { Abstract_chain_element::register_progress_watcher (new_progress_watcher); } 56  57  // Fix "inherits ... via dominance" warnings 58   uint64 get_id () const 59  { return Abstract_chain_element::get_id (); } 60  61  void stop_queue (); 62  63 protected: 64  // Fix "inherits ... via dominance" warnings 65   void item_completion_in_child_callback ( Item_processing_data * item_processed) 66  { Abstract_chain_element::item_completion_in_child_callback (item_processed); } 67  68 private: 69  void queue_thread (); 70  71  void task_availability_callback (const Abstract_dump_task * available_task); 72  73  void add_ready_items_to_queue ( 74  std::map <const I_dump_task *, std::vector<Item_processing_data*>* > 75  ::iterator it); 76  77  /* 78  Group of threads to process objects on queue. 79  */ 80   my_boost::thread_group m_thread_group ; 81   my_boost::mutex m_queue_mutex ; 82  /* 83  Maps task to all processing items that processes specified task. 84  */ 85  std::map<const I_dump_task*, std::vector<Item_processing_data*>*> 86   m_tasks_map ; 87   std::queue<Item_processing_data*> m_items_ready_for_processing ; 88  /* 89  Standard callback on task completion to run all possible dependent tasks. 90  */ 91  Mysql::Instance_callback<void, const Abstract_dump_task*, Object_queue> 92   m_task_availability_callback ; 93  /* 94  Indicates if queue is running. If set to false, all pending and being 95  processed tasks should complete, then queue is ready to close. 96  */ 97   my_boost::atomic_bool m_is_queue_running ; 98  /* 99  Callback called when created thread is starting or exiting. Call is done in 100  execution context of created thread. Parameter value 101  of true is used for thread start, false for thread exit. 102  */ 103   Mysql::I_callable<void, bool> * m_thread_callback ; 104   Mysql::Tools::Base::Abstract_program * m_program ; 105 }; 106  107 } 108 } 109 } 110  111 #endif Mysql::Tools::Dump::Object_queue::m_items_ready_for_processing std::queue< Item_processing_data * > m_items_ready_for_processing Definition: object_queue.h:87 uint unsigned int uint Definition: my_global.h:422 Mysql::Tools::Dump::Object_queue::add_ready_items_to_queue void add_ready_items_to_queue(std::map< const I_dump_task *, std::vector< Item_processing_data * > * >::iterator it) Definition: object_queue.cc:25 program static Program program Definition: program.cc:273 Mysql::Tools::Dump::Object_queue::queue_thread void queue_thread() Definition: object_queue.cc:53 Mysql::Tools::Dump::Object_queue::m_is_queue_running my_boost::atomic_bool m_is_queue_running Definition: object_queue.h:97 Mysql::Tools::Dump::Object_queue::item_completion_in_child_callback void item_completion_in_child_callback(Item_processing_data *item_processed) This callback can be requested to be called by child for any