activemq-cpp-3.8.2
Atomics.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _DECAF_INTERNAL_UTIL_CONCURRENT_ATOMICS_H_
19 #define _DECAF_INTERNAL_UTIL_CONCURRENT_ATOMICS_H_
20 
21 #include <decaf/util/Config.h>
22 
23 namespace decaf {
24 namespace internal {
25 namespace util {
26 namespace concurrent {
27 
28  class Threading;
29 
31  private:
32 
33  Atomics();
34  Atomics(const Atomics&);
35  Atomics& operator= (const Atomics&);
36 
37  public:
38 
39  template<typename T>
40  static bool compareAndSwap(T*& target, T* expect, T* update) {
41 
42  return Atomics::compareAndSet((volatile void**)&target, (void*)expect, (void*)update);
43  }
44 
45  public:
46 
47  static bool compareAndSet32(volatile int* target, int expect, int update);
48  static bool compareAndSet(volatile void** target, void* expect, void* update);
49 
50  static void* getAndSet(volatile void** target, void* value);
51  static int getAndSet(volatile int* target, int value);
52 
53  static int getAndIncrement(volatile int* target);
54  static int getAndDecrement(volatile int* target);
55 
56  static int getAndAdd(volatile int* target, int delta);
57  static int addAndGet(volatile int* target, int delta);
58 
59  static int incrementAndGet(volatile int* target);
60  static int decrementAndGet(volatile int* target);
61 
62  private:
63 
64  static void initialize();
65  static void shutdown();
66 
67  friend class Threading;
68  };
69 
70 }}}}
71 
72 #endif /* _DECAF_INTERNAL_UTIL_CONCURRENT_ATOMICS_H_ */
static bool compareAndSet(volatile void **target, void *expect, void *update)
#define DECAF_API
Definition: Config.h:29
static bool compareAndSwap(T *&target, T *expect, T *update)
Definition: Atomics.h:40
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25