libXDispatch 0.3.1
include/libdispatch/base.h
Go to the documentation of this file.
00001 /*
00002 * Copyright (c) 2008-2009 Apple Inc. All rights reserved.
00003 * Copyright (c) 2011 MLBA. All rights reserved.
00004 *
00005 * @MLBA_OPEN_LICENSE_HEADER_START@
00006 *
00007 * Licensed under the Apache License, Version 2.0 (the "License");
00008 * you may not use this file except in compliance with the License.
00009 * You may obtain a copy of the License at
00010 * 
00011 *     http://www.apache.org/licenses/LICENSE-2.0
00012 * 
00013 * Unless required by applicable law or agreed to in writing, software
00014 * distributed under the License is distributed on an "AS IS" BASIS,
00015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016 * See the License for the specific language governing permissions and
00017 * limitations under the License.
00018 *
00019 * @MLBA_OPEN_LICENSE_HEADER_END@
00020 */
00021 
00022 #ifndef __DISPATCH_BASE__
00023 #define __DISPATCH_BASE__
00024 
00025 #ifndef __DISPATCH_INDIRECT__
00026 #error "Please #include <xdispatch/dispatch.h> instead of this file directly."
00027 #endif
00028 
00029 typedef void (*dispatch_function_t)(void *);
00030 
00031 #ifndef ATOMIC_INT
00032 
00033 #ifdef __GNUC__
00034 # define ATOMIC_INT unsigned int
00035 #endif
00036 #ifdef _MSC_VER
00037 # if _MSC_VER >= 1600
00038 #      define ATOMIC_INT unsigned int
00039 # else
00040 #      define ATOMIC_INT long
00041 # endif
00042 #endif
00043 
00044 #endif
00045 
00046 #ifndef DISPATCH_EXPORT
00047 # if __GNUC__
00048 #   define DISPATCH_EXPORT __attribute__((visibility("default")))
00049 # elif _WIN32
00050 #   define DISPATCH_EXPORT __declspec(dllexport)
00051 # else
00052 #   define DISPATCH_EXPORT
00053 # endif
00054 #endif
00055 
00056 #ifdef __cplusplus
00057 /*
00058  * Dispatch objects are NOT C++ objects. Nevertheless, we can at least keep C++
00059  * aware of type compatibility.
00060  */
00061 typedef struct dispatch_object_s {
00062 public:
00063        void* context;
00064        int type;
00065        unsigned int count;
00066        ATOMIC_INT lock;
00067        dispatch_function_t finalizer;
00068        void* target;
00069        char suspended;
00070     void* obj;
00071 private:
00072        dispatch_object_s();
00073        dispatch_object_s(const dispatch_object_s &);
00074        void operator=(const dispatch_object_s &);
00075 } *dispatch_object_t;
00076 #else
00077 typedef struct dispatch_object_s {
00078        void* context;
00079        int type;
00080        unsigned int count;
00081        ATOMIC_INT lock;
00082        dispatch_function_t finalizer;
00083        void* target;
00084        char suspended;
00085     void* obj;
00086 } *dispatch_object_t;
00087 #endif
00088 
00089 #ifdef __cplusplus
00090 #      define DISPATCH_DECL(name) typedef struct name##_s : public dispatch_object_s {} *name##_t
00091 #else
00092 #      define DISPATCH_DECL(name) typedef struct dispatch_object_s *name##_t
00093 #endif
00094 
00095 
00096 #endif

Generated on Wed Feb 22 2012 19:43:56 for libXDispatch by Doxygen 1.7.4
Content © 2011-2012 MLBA (about | privacy) – Design © 2010-2012 Emzeat. All Rights reserved.