21 #include "kinetic/threadsafe_nonblocking_connection.h"
26 using std::shared_ptr;
29 ThreadsafeNonblockingKineticConnection::ThreadsafeNonblockingKineticConnection(
30 unique_ptr<NonblockingKineticConnection> connection) {
31 connection_ = std::move(connection);
34 ThreadsafeNonblockingKineticConnection::~ThreadsafeNonblockingKineticConnection() {
37 bool ThreadsafeNonblockingKineticConnection::Run(fd_set *read_fds, fd_set *write_fds,
int *nfds) {
38 std::lock_guard<std::recursive_mutex> guard(mutex_);
39 return connection_->Run(read_fds, write_fds, nfds);
42 bool ThreadsafeNonblockingKineticConnection::RemoveHandler(HandlerKey handler_key) {
43 std::lock_guard<std::recursive_mutex> guard(mutex_);
44 return connection_->RemoveHandler(handler_key);
47 void ThreadsafeNonblockingKineticConnection::SetClientClusterVersion(int64_t cluster_version) {
48 std::lock_guard<std::recursive_mutex> guard(mutex_);
49 return connection_->SetClientClusterVersion(cluster_version);
52 HandlerKey ThreadsafeNonblockingKineticConnection::NoOp(
const shared_ptr<SimpleCallbackInterface> callback) {
53 std::lock_guard<std::recursive_mutex> guard(mutex_);
54 return connection_->NoOp(callback);
57 HandlerKey ThreadsafeNonblockingKineticConnection::Get(
const shared_ptr<const string> key,
const shared_ptr<GetCallbackInterface> callback) {
58 std::lock_guard<std::recursive_mutex> guard(mutex_);
59 return connection_->Get(key, callback);
62 HandlerKey ThreadsafeNonblockingKineticConnection::Get(
const string key,
const shared_ptr<GetCallbackInterface> callback) {
63 std::lock_guard<std::recursive_mutex> guard(mutex_);
64 return connection_->Get(key, callback);
68 HandlerKey ThreadsafeNonblockingKineticConnection::GetNext(
const string key,
const shared_ptr<GetCallbackInterface> callback){
69 std::lock_guard<std::recursive_mutex> guard(mutex_);
70 return connection_->GetNext(key, callback);
73 HandlerKey ThreadsafeNonblockingKineticConnection::GetNext(
const shared_ptr<const string> key,
74 const shared_ptr<GetCallbackInterface> callback) {
75 std::lock_guard<std::recursive_mutex> guard(mutex_);
76 return connection_->GetNext(key, callback);
79 HandlerKey ThreadsafeNonblockingKineticConnection::GetPrevious(
const shared_ptr<const string> key,
80 const shared_ptr<GetCallbackInterface> callback) {
81 std::lock_guard<std::recursive_mutex> guard(mutex_);
82 return connection_->GetPrevious(key, callback);
85 HandlerKey ThreadsafeNonblockingKineticConnection::GetPrevious(
const string key,
const shared_ptr<GetCallbackInterface> callback){
86 std::lock_guard<std::recursive_mutex> guard(mutex_);
87 return connection_->GetPrevious(key, callback);
90 HandlerKey ThreadsafeNonblockingKineticConnection::GetVersion(
const string key,
const shared_ptr<GetVersionCallbackInterface> callback){
91 std::lock_guard<std::recursive_mutex> guard(mutex_);
92 return connection_->GetVersion(key, callback);
95 HandlerKey ThreadsafeNonblockingKineticConnection::GetVersion(
const shared_ptr<const string> key,
96 const shared_ptr<GetVersionCallbackInterface> callback) {
97 std::lock_guard<std::recursive_mutex> guard(mutex_);
98 return connection_->GetVersion(key, callback);
101 HandlerKey ThreadsafeNonblockingKineticConnection::GetKeyRange(
102 const shared_ptr<const string> start_key,
103 bool start_key_inclusive,
104 const shared_ptr<const string> end_key,
105 bool end_key_inclusive,
106 bool reverse_results,
108 const shared_ptr<GetKeyRangeCallbackInterface> callback) {
109 std::lock_guard<std::recursive_mutex> guard(mutex_);
110 return connection_->GetKeyRange(start_key, start_key_inclusive, end_key,
111 end_key_inclusive, reverse_results, max_results, callback);
114 HandlerKey ThreadsafeNonblockingKineticConnection::GetKeyRange(
const string start_key,
bool start_key_inclusive,
115 const string end_key,
bool end_key_inclusive,
116 bool reverse_results, int32_t max_results,
const shared_ptr<GetKeyRangeCallbackInterface> callback){
117 std::lock_guard<std::recursive_mutex> guard(mutex_);
118 return connection_->GetKeyRange(start_key, start_key_inclusive, end_key,
119 end_key_inclusive, reverse_results, max_results, callback);
122 HandlerKey ThreadsafeNonblockingKineticConnection::Put(
const shared_ptr<const string> key,
const shared_ptr<const string> current_version, WriteMode mode,
123 const shared_ptr<const KineticRecord> record,
const shared_ptr<PutCallbackInterface> callback){
124 std::lock_guard<std::recursive_mutex> guard(mutex_);
125 return connection_->Put(key, current_version, mode, record, callback);
127 HandlerKey ThreadsafeNonblockingKineticConnection::Put(
const string key,
const string current_version, WriteMode mode,
128 const shared_ptr<const KineticRecord> record,
const shared_ptr<PutCallbackInterface> callback){
129 std::lock_guard<std::recursive_mutex> guard(mutex_);
130 return connection_->Put(key, current_version, mode, record, callback);
132 HandlerKey ThreadsafeNonblockingKineticConnection::Put(
const shared_ptr<const string> key,
const shared_ptr<const string> current_version, WriteMode mode,
133 const shared_ptr<const KineticRecord> record,
const shared_ptr<PutCallbackInterface> callback,
134 PersistMode persistMode){
135 std::lock_guard<std::recursive_mutex> guard(mutex_);
136 return connection_->Put(key, current_version, mode, record, callback, persistMode);
138 HandlerKey ThreadsafeNonblockingKineticConnection::Put(
const string key,
const string current_version, WriteMode mode,
139 const shared_ptr<const KineticRecord> record,
const shared_ptr<PutCallbackInterface> callback,
140 PersistMode persistMode){
141 std::lock_guard<std::recursive_mutex> guard(mutex_);
142 return connection_->Put(key, current_version, mode, record, callback, persistMode);
145 HandlerKey ThreadsafeNonblockingKineticConnection::Delete(
const shared_ptr<const string> key,
const shared_ptr<const string> version, WriteMode mode,
146 const shared_ptr<SimpleCallbackInterface> callback, PersistMode persistMode){
147 std::lock_guard<std::recursive_mutex> guard(mutex_);
148 return connection_->Delete(key, version, mode, callback, persistMode);
150 HandlerKey ThreadsafeNonblockingKineticConnection::Delete(
const string key,
const string version, WriteMode mode,
151 const shared_ptr<SimpleCallbackInterface> callback, PersistMode persistMode){
152 std::lock_guard<std::recursive_mutex> guard(mutex_);
153 return connection_->Delete(key, version, mode, callback, persistMode);
155 HandlerKey ThreadsafeNonblockingKineticConnection::Delete(
const shared_ptr<const string> key,
const shared_ptr<const string> version, WriteMode mode,
156 const shared_ptr<SimpleCallbackInterface> callback){
157 std::lock_guard<std::recursive_mutex> guard(mutex_);
158 return connection_->Delete(key, version, mode, callback);
160 HandlerKey ThreadsafeNonblockingKineticConnection::Delete(
const string key,
const string version, WriteMode mode,
161 const shared_ptr<SimpleCallbackInterface> callback){
162 std::lock_guard<std::recursive_mutex> guard(mutex_);
163 return connection_->Delete(key, version, mode, callback);
166 HandlerKey ThreadsafeNonblockingKineticConnection::InstantErase(
const string pin,
const shared_ptr<SimpleCallbackInterface> callback){
167 std::lock_guard<std::recursive_mutex> guard(mutex_);
168 return connection_->InstantErase(pin, callback);
170 HandlerKey ThreadsafeNonblockingKineticConnection::InstantErase(
const shared_ptr<string> pin,
171 const shared_ptr<SimpleCallbackInterface> callback) {
172 std::lock_guard<std::recursive_mutex> guard(mutex_);
173 return connection_->InstantErase(pin, callback);
176 HandlerKey ThreadsafeNonblockingKineticConnection::SecureErase(
const string pin,
const shared_ptr<SimpleCallbackInterface> callback){
177 std::lock_guard<std::recursive_mutex> guard(mutex_);
178 return connection_->SecureErase(pin, callback);
180 HandlerKey ThreadsafeNonblockingKineticConnection::SecureErase(
const shared_ptr<string> pin,
181 const shared_ptr<SimpleCallbackInterface> callback) {
182 std::lock_guard<std::recursive_mutex> guard(mutex_);
183 return connection_->SecureErase(pin, callback);
186 HandlerKey ThreadsafeNonblockingKineticConnection::SetClusterVersion(int64_t new_cluster_version,
187 const shared_ptr<SimpleCallbackInterface> callback) {
188 std::lock_guard<std::recursive_mutex> guard(mutex_);
189 return connection_->SetClusterVersion(new_cluster_version, callback);
192 HandlerKey ThreadsafeNonblockingKineticConnection::GetLog(
193 const shared_ptr<GetLogCallbackInterface> callback) {
194 std::lock_guard<std::recursive_mutex> guard(mutex_);
195 return connection_->GetLog(callback);
197 HandlerKey ThreadsafeNonblockingKineticConnection::GetLog(
const vector<Command_GetLog_Type>& types,
198 const shared_ptr<GetLogCallbackInterface> callback) {
199 std::lock_guard<std::recursive_mutex> guard(mutex_);
200 return connection_->GetLog(types, callback);
203 HandlerKey ThreadsafeNonblockingKineticConnection::UpdateFirmware(
204 const shared_ptr<const string> new_firmware,
205 const shared_ptr<SimpleCallbackInterface> callback) {
206 std::lock_guard<std::recursive_mutex> guard(mutex_);
207 return connection_->UpdateFirmware(new_firmware, callback);
210 HandlerKey ThreadsafeNonblockingKineticConnection::SetACLs(
const shared_ptr<
const list<ACL>> acls,
211 const shared_ptr<SimpleCallbackInterface> callback) {
212 std::lock_guard<std::recursive_mutex> guard(mutex_);
213 return connection_->SetACLs(acls, callback);
216 HandlerKey ThreadsafeNonblockingKineticConnection::SetErasePIN(
const shared_ptr<const string> new_pin,
217 const shared_ptr<const string> current_pin,
218 const shared_ptr<SimpleCallbackInterface> callback) {
219 std::lock_guard<std::recursive_mutex> guard(mutex_);
220 return connection_->SetErasePIN(new_pin, current_pin, callback);
223 HandlerKey ThreadsafeNonblockingKineticConnection::SetErasePIN(
const string new_pin,
const string current_pin,
const shared_ptr<SimpleCallbackInterface> callback) {
224 std::lock_guard<std::recursive_mutex> guard(mutex_);
225 return connection_->SetErasePIN(new_pin, current_pin, callback);
228 HandlerKey ThreadsafeNonblockingKineticConnection::LockDevice(
const string pin,
const shared_ptr<SimpleCallbackInterface> callback){
229 std::lock_guard<std::recursive_mutex> guard(mutex_);
230 return connection_->LockDevice(pin, callback);
232 HandlerKey ThreadsafeNonblockingKineticConnection::LockDevice(
const shared_ptr<string> pin,
233 const shared_ptr<SimpleCallbackInterface> callback) {
234 std::lock_guard<std::recursive_mutex> guard(mutex_);
235 return connection_->LockDevice(pin, callback);
238 HandlerKey ThreadsafeNonblockingKineticConnection::UnlockDevice(
const string pin,
const shared_ptr<SimpleCallbackInterface> callback){
239 std::lock_guard<std::recursive_mutex> guard(mutex_);
240 return connection_->UnlockDevice(pin, callback);
242 HandlerKey ThreadsafeNonblockingKineticConnection::UnlockDevice(
const shared_ptr<string> pin,
243 const shared_ptr<SimpleCallbackInterface> callback) {
244 std::lock_guard<std::recursive_mutex> guard(mutex_);
245 return connection_->UnlockDevice(pin, callback);
248 HandlerKey ThreadsafeNonblockingKineticConnection::SetLockPIN(
const shared_ptr<const string> new_pin,
249 const shared_ptr<const string> current_pin,
250 const shared_ptr<SimpleCallbackInterface> callback) {
251 std::lock_guard<std::recursive_mutex> guard(mutex_);
252 return connection_->SetLockPIN(new_pin, current_pin, callback);
255 HandlerKey ThreadsafeNonblockingKineticConnection::SetLockPIN(
const string new_pin,
const string current_pin,
const shared_ptr<SimpleCallbackInterface> callback) {
256 std::lock_guard<std::recursive_mutex> guard(mutex_);
257 return connection_->SetLockPIN(new_pin, current_pin, callback);
260 HandlerKey ThreadsafeNonblockingKineticConnection::P2PPush(
261 const shared_ptr<const P2PPushRequest> push_request,
262 const shared_ptr<P2PPushCallbackInterface> callback) {
263 std::lock_guard<std::recursive_mutex> guard(mutex_);
264 return connection_->P2PPush(push_request, callback);
267 HandlerKey ThreadsafeNonblockingKineticConnection::P2PPush(
const P2PPushRequest& push_request,
268 const shared_ptr<P2PPushCallbackInterface> callback) {
269 std::lock_guard<std::recursive_mutex> guard(mutex_);
270 return connection_->P2PPush(push_request, callback);