Hazelcast C++ Client
ILock.h
1 /*
2  * Copyright (c) 2008-2018, Hazelcast, Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 //
17 // Created by sancar koyunlu on 6/27/13.
18 
19 #ifndef HAZELCAST_ILock
20 #define HAZELCAST_ILock
21 
22 #include <string>
23 
24 #include "hazelcast/client/spi/ClientContext.h"
25 #include "hazelcast/client/proxy/ProxyImpl.h"
26 #include "hazelcast/client/serialization/pimpl/Data.h"
27 #include "hazelcast/client/impl/ClientLockReferenceIdGenerator.h"
28 
29 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
30 #pragma warning(push)
31 #pragma warning(disable: 4251) //for dll export
32 #endif
33 
34 namespace hazelcast {
35  namespace client {
36 
41  class HAZELCAST_API ILock : public proxy::ProxyImpl {
42  friend class impl::HazelcastClientInstanceImpl;
43 
44  public:
45 
50  void lock();
51 
58  void lock(long leaseTimeInMillis);
59 
63  void unlock();
64 
69  void forceUnlock();
70 
75  bool isLocked();
76 
81  bool isLockedByCurrentThread();
82 
88  int getLockCount();
89 
96  long getRemainingLeaseTime();
97 
103  bool tryLock();
104 
112  bool tryLock(long timeInMillis);
113 
114  protected:
115  virtual void onInitialize();
116 
117  private:
118 
119  ILock(const std::string& instanceName, spi::ClientContext *context);
120 
121  serialization::pimpl::Data key;
122  int partitionId;
123  boost::shared_ptr<impl::ClientLockReferenceIdGenerator> referenceIdGenerator;
124  };
125  }
126 }
127 
128 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
129 #pragma warning(pop)
130 #endif
131 
132 #endif //HAZELCAST_ILock
133 
Re-entrant Lock, Distributed client implementation of Lock.
Definition: ILock.h:41
Definition: MapEntryView.h:32