Hazelcast C++ Client
 All Classes Functions Variables Enumerations Pages
ISemaphore.h
1 /*
2  * Copyright (c) 2008-2015, 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 
25 namespace hazelcast {
26  namespace client {
57  class HAZELCAST_API ISemaphore : public proxy::ProxyImpl {
58  friend class HazelcastClient;
59 
60  public:
61 
67  bool init(int permits);
68 
95  void acquire();
96 
127  void acquire(int permits);
128 
129 
138  int availablePermits();
139 
140 
146  int drainPermits();
147 
156  void reducePermits(int reduction);
157 
168  void release();
169 
181  void release(int permits);
182 
194  bool tryAcquire();
195 
209  bool tryAcquire(int permits);
210 
252  bool tryAcquire(long timeoutInMillis);
253 
293  bool tryAcquire(int permits, long timeoutInMillis);
294 
295  private:
296 
297  ISemaphore(const std::string &instanceName, spi::ClientContext *context);
298 
299  int partitionId;
300  };
301  }
302 }
303 
304 #endif /* HAZELCAST_ISEMAPHORE */
ISemaphore is a backed-up distributed alternative to the java.util.concurrent.Semaphore.
Definition: ISemaphore.h:57
Hazelcast Client enables you to do all Hazelcast operations without being a member of the cluster...
Definition: HazelcastClient.h:410