0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SshThreadsCallbacks.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2014 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
26 
27 #ifndef Tools_cluster_SshThreadsCallbacks_h
28 #define Tools_cluster_SshThreadsCallbacks_h
29 
30 #include <libssh/callbacks.h>
31 
32 #include <mutex>
33 #include <thread>
34 #include <unordered_map>
35 
36 namespace Hypertable {
37 
40 
43 
44  public:
45 
50  static int mutex_init (void **priv);
51 
56  static int mutex_destroy (void **lock);
57 
62  static int mutex_lock (void **lock);
63 
68  static int mutex_unlock (void **lock);
69 
71  static unsigned long thread_id ();
72 
78  static struct ssh_threads_callbacks_struct *get();
79 
80  private:
81 
84 
86  static unsigned long ms_thread_id_next;
87 
89  static std::unordered_map<std::thread::id, int> ms_thread_id_map;
90 
92  static struct ssh_threads_callbacks_struct ms_callbacks;
93 
94  };
95 
97 }
98 
99 #endif // Tools_cluster_SshThreadsCallbacks_h
100 
101 
static std::mutex mutex
Definition: Logger.cc:43
static unsigned long thread_id()
Callback for obtaining current thread ID.
static int mutex_init(void **priv)
Mutex initializaton callback.
static std::unordered_map< std::thread::id, int > ms_thread_id_map
Mapping from std::thread::id to unique thread ID number.
static std::mutex ms_thread_id_mutex
Mutex for serializing access to static data members
static unsigned long ms_thread_id_next
Next thread ID.
static int mutex_destroy(void **lock)
Mutex destroy callback.
static int mutex_unlock(void **lock)
Mutex unlock callback.
static struct ssh_threads_callbacks_struct ms_callbacks
libssh callbacks structure
static int mutex_lock(void **lock)
Mutex lock callback.
Hypertable definitions
Thread callbacks for libssh