libXDispatch 0.6
include/xdispatch/semaphore.h
Go to the documentation of this file.
00001 
00002 /*
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 
00023 #ifndef XDISPATCH_SEMAPHORE_H_
00024 #define XDISPATCH_SEMAPHORE_H_
00025 
00026 #ifndef __XDISPATCH_INDIRECT__
00027 #error "Please #include <xdispatch/dispatch.h> instead of this file directly."
00028 #endif
00029 
00030 #include <memory>
00031 
00032 __XDISPATCH_BEGIN_NAMESPACE
00033 
00042 class XDISPATCH_EXPORT semaphore {
00043 
00044 public:
00056     semaphore(int = 1);
00061     semaphore(dispatch_semaphore_t);
00062     semaphore(const semaphore&);
00063     ~semaphore();
00064 
00074     int release();
00082     void acquire();
00092     bool try_acquire(dispatch_time_t);
00102     bool try_acquire(struct tm*);
00108     virtual const dispatch_semaphore_t native() const;
00109 
00110        semaphore& operator=(const semaphore&);
00111        bool operator ==(const semaphore&);
00112        bool operator ==(const dispatch_semaphore_t&);
00113        bool operator !=(const semaphore&);
00114        bool operator !=(const dispatch_semaphore_t&);
00115 
00116 private:
00117     class data;
00118     data* d;
00119 
00120 };
00121 
00122 XDISPATCH_EXPORT std::ostream& operator<<(std::ostream&, const semaphore*);
00123 XDISPATCH_EXPORT std::ostream& operator<<(std::ostream&, const semaphore&);
00124 
00125 XDISPATCH_EXPORT bool operator ==(const dispatch_semaphore_t&, const semaphore&);
00126 XDISPATCH_EXPORT bool operator !=(const dispatch_semaphore_t&, const semaphore&);
00127 
00128 __XDISPATCH_END_NAMESPACE
00129 
00130 #endif /* XDISPATCH_SEMAPHORE_H_ */

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