libXDispatch 0.4
include/xdispatch/timer.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_TIMER_H_
00024 #define XDISPATCH_TIMER_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 
00043 class XDISPATCH_EXPORT timer {
00044 
00045 public:
00052     timer(uint64_t interval, const xdispatch::queue& target = global_queue());
00053     timer(const timer&);
00054     timer(dispatch_source_t);
00055     ~timer();
00056 
00062     void interval(uint64_t);
00068     void latency(uint64_t);
00074     void start();
00080     void stop();
00087     void handler(xdispatch::operation*);
00088 #ifdef XDISPATCH_HAS_BLOCKS
00089 
00092     void handler(dispatch_block_t);
00093 #endif
00094 
00097     void set_queue(const xdispatch::queue&);
00101     xdispatch::queue queue();
00105     virtual const dispatch_source_t native() const;
00110     static timer* current();
00115     static void single_shot(dispatch_time_t, const xdispatch::queue&, xdispatch::operation*);
00120     static void single_shot(struct tm*, const xdispatch::queue&, xdispatch::operation*);
00121 #ifdef XDISPATCH_HAS_BLOCKS
00122 
00126     static void single_shot(dispatch_time_t, const xdispatch::queue&, dispatch_block_t);
00131     static void single_shot(struct tm*, const xdispatch::queue&, dispatch_block_t);
00132 #endif
00133 
00134 private:
00135     class data;
00136     data* d;
00137 
00138 };
00139 
00140 XDISPATCH_EXPORT std::ostream& operator<<(std::ostream& stream, const timer*);
00141 XDISPATCH_EXPORT std::ostream& operator<<(std::ostream& stream, const timer&);
00142 
00143 __XDISPATCH_END_NAMESPACE
00144 
00145 #endif /* XDISPATCH_TIMER_H_ */

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