Hazelcast C++ Client
ISemaphore.h
1 /*
2  * Copyright (c) 2008-2017, 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 #ifndef HAZELCAST_ISEMAPHORE
17 #define HAZELCAST_ISEMAPHORE
18 
19 #include "hazelcast/client/proxy/ProxyImpl.h"
20 #include "hazelcast/client/exception/IException.h"
21 #include <string>
22 #include <stdexcept>
23 
24 namespace hazelcast {
25  namespace client {
56  class HAZELCAST_API ISemaphore : public proxy::ProxyImpl {
57  friend class HazelcastClient;
58 
59  public:
60 
66  bool init(int permits);
67 
94  void acquire();
95 
126  void acquire(int permits);
127 
128 
137  int availablePermits();
138 
139 
145  int drainPermits();
146 
155  void reducePermits(int reduction);
156 
167  void release();
168 
180  void release(int permits);
181 
193  bool tryAcquire();
194 
208  bool tryAcquire(int permits);
209 
251  bool tryAcquire(long timeoutInMillis);
252 
292  bool tryAcquire(int permits, long timeoutInMillis);
293 
294  private:
295 
296  ISemaphore(const std::string &instanceName, spi::ClientContext *context);
297 
298  int partitionId;
299  };
300  }
301 }
302 
303 #endif /* HAZELCAST_ISEMAPHORE */
Definition: MapEntryView.h:32
ISemaphore is a backed-up distributed alternative to the java.util.concurrent.Semaphore.
Definition: ISemaphore.h:56
Hazelcast Client enables you to do all Hazelcast operations without being a member of the cluster...
Definition: HazelcastClient.h:459