diff options
author | unknown <kostja@bodhi.local> | 2006-11-17 16:11:04 +0300 |
---|---|---|
committer | unknown <kostja@bodhi.local> | 2006-11-17 16:11:04 +0300 |
commit | a163ae30f23239e1f7a9efafc620e1bc74e009ba (patch) | |
tree | 5ecdad467c796454f72a94e294ff4958563441fb /server-tools/instance-manager/thread_registry.h | |
parent | 211b2bc92a25609e0c7323b5fee6f646abb3c748 (diff) | |
download | mariadb-git-a163ae30f23239e1f7a9efafc620e1bc74e009ba.tar.gz |
Replace the approach using Foo_thread_args + Foo_thread and manually
spawned threads with a reusable class Thread.
This is the second idea implemented in the Alik's patch for
BUG#22306: STOP INSTANCE can not be applied for instances in Crashed,
Failed and Abandoned.
Commiting separately to ease review process.
server-tools/instance-manager/commands.cc:
Remove an unused header.
server-tools/instance-manager/guardian.cc:
Use Thread framework instead of manually spawning the Guardian thread.
Tidy up.
server-tools/instance-manager/guardian.h:
Use Thread framework instead of manually spawning the Guardian thread.
server-tools/instance-manager/instance.cc:
Use Thread framework instead of manually spawning the instance
monitoring thread.
server-tools/instance-manager/listener.cc:
Use Thread framework instead of manually spawning the
mysql connection thread.
server-tools/instance-manager/listener.h:
Use Thread framework instead of manually spawning the
mysql connection thread.
Rename Listener_thread to Listener for brevity.
server-tools/instance-manager/manager.cc:
Change references to pointers, as per the coding style.
Use Thread framework instead of manually spawning threads.
server-tools/instance-manager/mysql_connection.cc:
Get rid of Mysql_connection_thread_args. Use class Thread framework
instead. Rename Mysql_connection_thread to Mysql_connection for brevity.
server-tools/instance-manager/mysql_connection.h:
Get rid of Mysql_connection_thread_args. Use class Thread framework
instead. Rename Mysql_connection_thread to Mysql_connection for brevity.
server-tools/instance-manager/priv.cc:
Move set_stacksize_and_create_thread to thread_registry.cc and make it
static: it is not used anywhere else now.
server-tools/instance-manager/priv.h:
No public set_stacksize_n_create_thread
server-tools/instance-manager/thread_registry.cc:
Implement a base Thread class to be used for all Instance Manager
threads.
server-tools/instance-manager/thread_registry.h:
Implement a base Thread class to be used for all Instance Manager
threads.
Diffstat (limited to 'server-tools/instance-manager/thread_registry.h')
-rw-r--r-- | server-tools/instance-manager/thread_registry.h | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/server-tools/instance-manager/thread_registry.h b/server-tools/instance-manager/thread_registry.h index 3af7c8e0240..034ac1b0ca8 100644 --- a/server-tools/instance-manager/thread_registry.h +++ b/server-tools/instance-manager/thread_registry.h @@ -57,7 +57,7 @@ #pragma interface #endif -/* +/** Thread_info - repository entry for each worker thread All entries comprise double-linked list like: 0 -- entry -- entry -- entry - 0 @@ -67,12 +67,10 @@ class Thread_info { public: - Thread_info(pthread_t thread_id_arg, bool send_signal_on_shutdown_arg); + Thread_info() {} friend class Thread_registry; - private: - Thread_info(); - + void init(bool send_signal_on_shutdown); private: pthread_cond_t *current_cond; Thread_info *prev, *next; @@ -81,7 +79,26 @@ private: }; -/* +/** + A base class for a detached thread. +*/ + +class Thread +{ +public: + Thread() {} + bool start_detached(); +protected: + virtual void run()= 0; + virtual ~Thread(); +private: + static void *thread_func(void *arg); + Thread(const Thread & /* rhs */); /* not implemented */ + Thread &operator=(const Thread & /* rhs */); /* not implemented */ +}; + + +/** Thread_registry - contains handles for each worker thread to deliver signal information to workers. */ @@ -92,7 +109,7 @@ public: Thread_registry(); ~Thread_registry(); - void register_thread(Thread_info *info); + void register_thread(Thread_info *info, bool send_signal_on_shutdown= TRUE); void unregister_thread(Thread_info *info); void deliver_shutdown(); void request_shutdown(); |