]> git.saurik.com Git - apple/libdispatch.git/blame - dispatch/io.h
libdispatch-187.10.tar.gz
[apple/libdispatch.git] / dispatch / io.h
CommitLineData
e85f4437
A
1/*
2 * Copyright (c) 2009-2010 Apple Inc. All rights reserved.
3 *
4 * @APPLE_APACHE_LICENSE_HEADER_START@
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * @APPLE_APACHE_LICENSE_HEADER_END@
19 */
20
21#ifndef __DISPATCH_IO__
22#define __DISPATCH_IO__
23
24#ifndef __DISPATCH_INDIRECT__
25#error "Please #include <dispatch/dispatch.h> instead of this file directly."
26#include <dispatch/base.h> // for HeaderDoc
27#endif
28
29__BEGIN_DECLS
30
31/*! @header
32 * Dispatch I/O provides both stream and random access asynchronous read and
33 * write operations on file descriptors. One or more dispatch I/O channels may
34 * be created from a file descriptor as either the DISPATCH_IO_STREAM type or
35 * DISPATCH_IO_RANDOM type. Once a channel has been created the application may
36 * schedule asynchronous read and write operations.
37 *
38 * The application may set policies on the dispatch I/O channel to indicate the
39 * desired frequency of I/O handlers for long-running operations.
40 *
41 * Dispatch I/O also provides a memory managment model for I/O buffers that
42 * avoids unnecessary copying of data when pipelined between channels. Dispatch
43 * I/O monitors the overall memory pressure and I/O access patterns for the
44 * application to optimize resource utilization.
45 */
46
47/*!
48 * @typedef dispatch_fd_t
49 * Native file descriptor type for the platform.
50 */
51typedef int dispatch_fd_t;
52
53#ifdef __BLOCKS__
54
55/*!
56 * @functiongroup Dispatch I/O Convenience API
57 * Convenience wrappers around the dispatch I/O channel API, with simpler
58 * callback handler semantics and no explicit management of channel objects.
59 * File descriptors passed to the convenience API are treated as streams, and
60 * scheduling multiple operations on one file descriptor via the convenience API
61 * may incur more overhead than by using the dispatch I/O channel API directly.
62 */
63
64/*!
65 * @function dispatch_read
66 * Schedule a read operation for asynchronous execution on the specified file
67 * descriptor. The specified handler is enqueued with the data read from the
68 * file descriptor when the operation has completed or an error occurs.
69 *
70 * The data object passed to the handler will be automatically released by the
71 * system when the handler returns. It is the responsibility of the application
72 * to retain, concatenate or copy the data object if it is needed after the
73 * handler returns.
74 *
75 * The data object passed to the handler will only contain as much data as is
76 * currently available from the file descriptor (up to the specified length).
77 *
78 * If an unrecoverable error occurs on the file descriptor, the handler will be
79 * enqueued with the appropriate error code along with a data object of any data
80 * that could be read successfully.
81 *
82 * An invocation of the handler with an error code of zero and an empty data
83 * object indicates that EOF was reached.
84 *
85 * The system takes control of the file descriptor until the handler is
86 * enqueued, and during this time file descriptor flags such as O_NONBLOCK will
87 * be modified by the system on behalf of the application. It is an error for
88 * the application to modify a file descriptor directly while it is under the
89 * control of the system, but it may create additional dispatch I/O convenience
90 * operations or dispatch I/O channels associated with that file descriptor.
91 *
92 * @param fd The file descriptor from which to read the data.
93 * @param length The length of data to read from the file descriptor,
94 * or SIZE_MAX to indicate that all of the data currently
95 * available from the file descriptor should be read.
96 * @param queue The dispatch queue to which the handler should be
97 * submitted.
98 * @param handler The handler to enqueue when data is ready to be
99 * delivered.
100 * @param data The data read from the file descriptor.
101 * @param error An errno condition for the read operation or
102 * zero if the read was successful.
103 */
104__OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0)
105DISPATCH_EXPORT DISPATCH_NONNULL3 DISPATCH_NONNULL4 DISPATCH_NOTHROW
106void
107dispatch_read(dispatch_fd_t fd,
108 size_t length,
109 dispatch_queue_t queue,
110 void (^handler)(dispatch_data_t data, int error));
111
112/*!
113 * @function dispatch_write
114 * Schedule a write operation for asynchronous execution on the specified file
115 * descriptor. The specified handler is enqueued when the operation has
116 * completed or an error occurs.
117 *
118 * If an unrecoverable error occurs on the file descriptor, the handler will be
119 * enqueued with the appropriate error code along with the data that could not
120 * be successfully written.
121 *
122 * An invocation of the handler with an error code of zero indicates that the
123 * data was fully written to the channel.
124 *
125 * The system takes control of the file descriptor until the handler is
126 * enqueued, and during this time file descriptor flags such as O_NONBLOCK will
127 * be modified by the system on behalf of the application. It is an error for
128 * the application to modify a file descriptor directly while it is under the
129 * control of the system, but it may create additional dispatch I/O convenience
130 * operations or dispatch I/O channels associated with that file descriptor.
131 *
132 * @param fd The file descriptor to which to write the data.
133 * @param data The data object to write to the file descriptor.
134 * @param queue The dispatch queue to which the handler should be
135 * submitted.
136 * @param handler The handler to enqueue when the data has been written.
137 * @param data The data that could not be written to the I/O
138 * channel, or NULL.
139 * @param error An errno condition for the write operation or
140 * zero if the write was successful.
141 */
142__OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0)
143DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NONNULL3 DISPATCH_NONNULL4
144DISPATCH_NOTHROW
145void
146dispatch_write(dispatch_fd_t fd,
147 dispatch_data_t data,
148 dispatch_queue_t queue,
149 void (^handler)(dispatch_data_t data, int error));
150
151/*!
152 * @functiongroup Dispatch I/O Channel API
153 */
154
155/*!
156 * @typedef dispatch_io_t
157 * A dispatch I/O channel represents the asynchronous I/O policy applied to a
158 * file descriptor. I/O channels are first class dispatch objects and may be
159 * retained and released, suspended and resumed, etc.
160 */
161DISPATCH_DECL(dispatch_io);
162
163/*!
164 * @typedef dispatch_io_handler_t
165 * The prototype of I/O handler blocks for dispatch I/O operations.
166 *
167 * @param done A flag indicating whether the operation is complete.
168 * @param data The data object to be handled.
169 * @param error An errno condition for the operation.
170 */
171typedef void (^dispatch_io_handler_t)(bool done, dispatch_data_t data,
172 int error);
173
174/*!
175 * @typedef dispatch_io_type_t
176 * The type of a dispatch I/O channel:
177 *
178 * @const DISPATCH_IO_STREAM A dispatch I/O channel representing a stream of
179 * bytes. Read and write operations on a channel of this type are performed
180 * serially (in order of creation) and read/write data at the file pointer
181 * position that is current at the time the operation starts executing.
182 * Operations of different type (read vs. write) may be perfomed simultaneously.
183 * Offsets passed to operations on a channel of this type are ignored.
184 *
185 * @const DISPATCH_IO_RANDOM A dispatch I/O channel representing a random
186 * access file. Read and write operations on a channel of this type may be
187 * performed concurrently and read/write data at the specified offset. Offsets
188 * are interpreted relative to the file pointer position current at the time the
189 * I/O channel is created. Attempting to create a channel of this type for a
190 * file descriptor that is not seekable will result in an error.
191 */
192#define DISPATCH_IO_STREAM 0
193#define DISPATCH_IO_RANDOM 1
194
195typedef unsigned long dispatch_io_type_t;
196
197/*!
198 * @function dispatch_io_create
199 * Create a dispatch I/O channel associated with a file descriptor. The system
200 * takes control of the file descriptor until the channel is closed, an error
201 * occurs on the file descriptor or all references to the channel are released.
202 * At that time the specified cleanup handler will be enqueued and control over
203 * the file descriptor relinquished.
204 *
205 * While a file descriptor is under the control of a dispatch I/O channel, file
206 * descriptor flags such as O_NONBLOCK will be modified by the system on behalf
207 * of the application. It is an error for the application to modify a file
208 * descriptor directly while it is under the control of a dispatch I/O channel,
209 * but it may create additional channels associated with that file descriptor.
210 *
211 * @param type The desired type of I/O channel (DISPATCH_IO_STREAM
212 * or DISPATCH_IO_RANDOM).
213 * @param fd The file descriptor to associate with the I/O channel.
214 * @param queue The dispatch queue to which the handler should be submitted.
215 * @param cleanup_handler The handler to enqueue when the system
216 * relinquishes control over the file descriptor.
217 * @param error An errno condition if control is relinquished
218 * because channel creation failed, zero otherwise.
219 * @result The newly created dispatch I/O channel or NULL if an error
220 * occurred.
221 */
222__OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0)
223DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_WARN_RESULT DISPATCH_NOTHROW
224dispatch_io_t
225dispatch_io_create(dispatch_io_type_t type,
226 dispatch_fd_t fd,
227 dispatch_queue_t queue,
228 void (^cleanup_handler)(int error));
229
230/*!
231* @function dispatch_io_create_with_path
232* Create a dispatch I/O channel associated with a path name. The specified
233* path, oflag and mode parameters will be passed to open(2) when the first I/O
234* operation on the channel is ready to execute and the resulting file
235* descriptor will remain open and under the control of the system until the
236* channel is closed, an error occurs on the file descriptor or all references
237* to the channel are released. At that time the file descriptor will be closed
238* and the specified cleanup handler will be enqueued.
239*
240* @param type The desired type of I/O channel (DISPATCH_IO_STREAM
241* or DISPATCH_IO_RANDOM).
242* @param path The path to associate with the I/O channel.
243* @param oflag The flags to pass to open(2) when opening the file at
244* path.
245* @param mode The mode to pass to open(2) when creating the file at
246* path (i.e. with flag O_CREAT), zero otherwise.
247* @param queue The dispatch queue to which the handler should be
248* submitted.
249* @param cleanup_handler The handler to enqueue when the system
250* has closed the file at path.
251* @param error An errno condition if control is relinquished
252* because channel creation or opening of the
253* specified file failed, zero otherwise.
254* @result The newly created dispatch I/O channel or NULL if an error
255* occurred.
256*/
257__OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0)
258DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_NONNULL2 DISPATCH_WARN_RESULT
259DISPATCH_NOTHROW
260dispatch_io_t
261dispatch_io_create_with_path(dispatch_io_type_t type,
262 const char *path, int oflag, mode_t mode,
263 dispatch_queue_t queue,
264 void (^cleanup_handler)(int error));
265
266/*!
267 * @function dispatch_io_create_with_io
268 * Create a new dispatch I/O channel from an existing dispatch I/O channel.
269 * The new channel inherits the file descriptor or path name associated with
270 * the existing channel, but not its channel type or policies.
271 *
272 * If the existing channel is associated with a file descriptor, control by the
273 * system over that file descriptor is extended until the new channel is also
274 * closed, an error occurs on the file descriptor, or all references to both
275 * channels are released. At that time the specified cleanup handler will be
276 * enqueued and control over the file descriptor relinquished.
277 *
278 * While a file descriptor is under the control of a dispatch I/O channel, file
279 * descriptor flags such as O_NONBLOCK will be modified by the system on behalf
280 * of the application. It is an error for the application to modify a file
281 * descriptor directly while it is under the control of a dispatch I/O channel,
282 * but it may create additional channels associated with that file descriptor.
283 *
284 * @param type The desired type of I/O channel (DISPATCH_IO_STREAM
285 * or DISPATCH_IO_RANDOM).
286 * @param io The existing channel to create the new I/O channel from.
287 * @param queue The dispatch queue to which the handler should be submitted.
288 * @param cleanup_handler The handler to enqueue when the system
289 * relinquishes control over the file descriptor
290 * (resp. closes the file at path) associated with
291 * the existing channel.
292 * @param error An errno condition if control is relinquished
293 * because channel creation failed, zero otherwise.
294 * @result The newly created dispatch I/O channel or NULL if an error
295 * occurred.
296 */
297__OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0)
298DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_MALLOC DISPATCH_WARN_RESULT
299DISPATCH_NOTHROW
300dispatch_io_t
301dispatch_io_create_with_io(dispatch_io_type_t type,
302 dispatch_io_t io,
303 dispatch_queue_t queue,
304 void (^cleanup_handler)(int error));
305
306/*!
307 * @function dispatch_io_read
308 * Schedule a read operation for asynchronous execution on the specified I/O
309 * channel. The I/O handler is enqueued one or more times depending on the
310 * general load of the system and the policy specified on the I/O channel.
311 *
312 * Any data read from the channel is described by the dispatch data object
313 * passed to the I/O handler. This object will be automatically released by the
314 * system when the I/O handler returns. It is the responsibility of the
315 * application to retain, concatenate or copy the data object if it is needed
316 * after the I/O handler returns.
317 *
318 * Dispatch I/O handlers are not reentrant. The system will ensure that no new
319 * I/O handler instance is invoked until the previously enqueued handler block
320 * has returned.
321 *
322 * An invocation of the I/O handler with the done flag set indicates that the
323 * read operation is complete and that the handler will not be enqueued again.
324 *
325 * If an unrecoverable error occurs on the I/O channel's underlying file
326 * descriptor, the I/O handler will be enqueued with the done flag set, the
327 * appropriate error code and a NULL data object.
328 *
329 * An invocation of the I/O handler with the done flag set, an error code of
330 * zero and an empty data object indicates that EOF was reached.
331 *
332 * @param channel The dispatch I/O channel from which to read the data.
333 * @param offset The offset relative to the channel position from which
334 * to start reading (only for DISPATCH_IO_RANDOM).
335 * @param length The length of data to read from the I/O channel, or
336 * SIZE_MAX to indicate that data should be read until EOF
337 * is reached.
338 * @param queue The dispatch queue to which the I/O handler should be
339 * submitted.
340 * @param io_handler The I/O handler to enqueue when data is ready to be
341 * delivered.
342 * @param done A flag indicating whether the operation is complete.
343 * @param data An object with the data most recently read from the
344 * I/O channel as part of this read operation, or NULL.
345 * @param error An errno condition for the read operation or zero if
346 * the read was successful.
347 */
348__OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0)
349DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL4 DISPATCH_NONNULL5
350DISPATCH_NOTHROW
351void
352dispatch_io_read(dispatch_io_t channel,
353 off_t offset,
354 size_t length,
355 dispatch_queue_t queue,
356 dispatch_io_handler_t io_handler);
357
358/*!
359 * @function dispatch_io_write
360 * Schedule a write operation for asynchronous execution on the specified I/O
361 * channel. The I/O handler is enqueued one or more times depending on the
362 * general load of the system and the policy specified on the I/O channel.
363 *
364 * Any data remaining to be written to the I/O channel is described by the
365 * dispatch data object passed to the I/O handler. This object will be
366 * automatically released by the system when the I/O handler returns. It is the
367 * responsibility of the application to retain, concatenate or copy the data
368 * object if it is needed after the I/O handler returns.
369 *
370 * Dispatch I/O handlers are not reentrant. The system will ensure that no new
371 * I/O handler instance is invoked until the previously enqueued handler block
372 * has returned.
373 *
374 * An invocation of the I/O handler with the done flag set indicates that the
375 * write operation is complete and that the handler will not be enqueued again.
376 *
377 * If an unrecoverable error occurs on the I/O channel's underlying file
378 * descriptor, the I/O handler will be enqueued with the done flag set, the
379 * appropriate error code and an object containing the data that could not be
380 * written.
381 *
382 * An invocation of the I/O handler with the done flag set and an error code of
383 * zero indicates that the data was fully written to the channel.
384 *
385 * @param channel The dispatch I/O channel on which to write the data.
386 * @param offset The offset relative to the channel position from which
387 * to start writing (only for DISPATCH_IO_RANDOM).
388 * @param data The data to write to the I/O channel. The data object
389 * will be retained by the system until the write operation
390 * is complete.
391 * @param queue The dispatch queue to which the I/O handler should be
392 * submitted.
393 * @param io_handler The I/O handler to enqueue when data has been delivered.
394 * @param done A flag indicating whether the operation is complete.
395 * @param data An object of the data remaining to be
396 * written to the I/O channel as part of this write
397 * operation, or NULL.
398 * @param error An errno condition for the write operation or zero
399 * if the write was successful.
400 */
401__OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0)
402DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NONNULL4
403DISPATCH_NONNULL5 DISPATCH_NOTHROW
404void
405dispatch_io_write(dispatch_io_t channel,
406 off_t offset,
407 dispatch_data_t data,
408 dispatch_queue_t queue,
409 dispatch_io_handler_t io_handler);
410
411/*!
412 * @typedef dispatch_io_close_flags_t
413 * The type of flags you can set on a dispatch_io_close() call
414 *
415 * @const DISPATCH_IO_STOP Stop outstanding operations on a channel when
416 * the channel is closed.
417 */
418#define DISPATCH_IO_STOP 0x1
419
420typedef unsigned long dispatch_io_close_flags_t;
421
422/*!
423 * @function dispatch_io_close
424 * Close the specified I/O channel to new read or write operations; scheduling
425 * operations on a closed channel results in their handler returning an error.
426 *
427 * If the DISPATCH_IO_STOP flag is provided, the system will make a best effort
428 * to interrupt any outstanding read and write operations on the I/O channel,
429 * otherwise those operations will run to completion normally.
430 * Partial results of read and write operations may be returned even after a
431 * channel is closed with the DISPATCH_IO_STOP flag.
432 * The final invocation of an I/O handler of an interrupted operation will be
433 * passed an ECANCELED error code, as will the I/O handler of an operation
434 * scheduled on a closed channel.
435 *
436 * @param channel The dispatch I/O channel to close.
437 * @param flags The flags for the close operation.
438 */
439__OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0)
440DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
441void
442dispatch_io_close(dispatch_io_t channel, dispatch_io_close_flags_t flags);
443
444/*!
445 * @function dispatch_io_barrier
446 * Schedule a barrier operation on the specified I/O channel; all previously
447 * scheduled operations on the channel will complete before the provided
448 * barrier block is enqueued onto the global queue determined by the channel's
449 * target queue, and no subsequently scheduled operations will start until the
450 * barrier block has returned.
451 *
452 * If multiple channels are associated with the same file descriptor, a barrier
453 * operation scheduled on any of these channels will act as a barrier across all
454 * channels in question, i.e. all previously scheduled operations on any of the
455 * channels will complete before the barrier block is enqueued, and no
456 * operations subsequently scheduled on any of the channels will start until the
457 * barrier block has returned.
458 *
459 * While the barrier block is running, it may safely operate on the channel's
460 * underlying file descriptor with fsync(2), lseek(2) etc. (but not close(2)).
461 *
462 * @param channel The dispatch I/O channel to close.
463 * @param barrier The flags for the close operation.
464 */
465__OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0)
466DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
467void
468dispatch_io_barrier(dispatch_io_t channel, dispatch_block_t barrier);
469
470/*!
471 * @function dispatch_io_get_descriptor
472 * Returns the file descriptor underlying a dispatch I/O channel.
473 *
474 * Will return -1 for a channel closed with dispatch_io_close() and for a
475 * channel associated with a path name that has not yet been open(2)ed.
476 *
477 * If called from a barrier block scheduled on a channel associated with a path
478 * name that has not yet been open(2)ed, this will trigger the channel open(2)
479 * operation and return the resulting file descriptor.
480 *
481 * @param channel The dispatch I/O channel to query.
482 * @result The file descriptor underlying the channel, or -1.
483 */
484__OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0)
485DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_WARN_RESULT DISPATCH_NOTHROW
486dispatch_fd_t
487dispatch_io_get_descriptor(dispatch_io_t channel);
488
489/*!
490 * @function dispatch_io_set_high_water
491 * Set a high water mark on the I/O channel for all operations.
492 *
493 * The system will make a best effort to enqueue I/O handlers with partial
494 * results as soon the number of bytes processed by an operation (i.e. read or
495 * written) reaches the high water mark.
496 *
497 * The size of data objects passed to I/O handlers for this channel will never
498 * exceed the specified high water mark.
499 *
500 * The default value for the high water mark is unlimited (i.e. SIZE_MAX).
501 *
502 * @param channel The dispatch I/O channel on which to set the policy.
503 * @param high_water The number of bytes to use as a high water mark.
504 */
505__OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0)
506DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
507void
508dispatch_io_set_high_water(dispatch_io_t channel, size_t high_water);
509
510/*!
511 * @function dispatch_io_set_low_water
512 * Set a low water mark on the I/O channel for all operations.
513 *
514 * The system will process (i.e. read or write) at least the low water mark
515 * number of bytes for an operation before enqueueing I/O handlers with partial
516 * results.
517 *
518 * The size of data objects passed to intermediate I/O handler invocations for
519 * this channel (i.e. excluding the final invocation) will never be smaller than
520 * the specified low water mark, except if the channel has an interval with the
521 * DISPATCH_IO_STRICT_INTERVAL flag set or if EOF or an error was encountered.
522 *
523 * I/O handlers should be prepared to receive amounts of data significantly
524 * larger than the low water mark in general. If an I/O handler requires
525 * intermediate results of fixed size, set both the low and and the high water
526 * mark to that size.
527 *
528 * The default value for the low water mark is unspecified, but must be assumed
529 * to be such that intermediate handler invocations may occur.
530 * If I/O handler invocations with partial results are not desired, set the
531 * low water mark to SIZE_MAX.
532 *
533 * @param channel The dispatch I/O channel on which to set the policy.
534 * @param low_water The number of bytes to use as a low water mark.
535 */
536__OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0)
537DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
538void
539dispatch_io_set_low_water(dispatch_io_t channel, size_t low_water);
540
541/*!
542 * @typedef dispatch_io_interval_flags_t
543 * Type of flags to set on dispatch_io_set_interval()
544 *
545 * @const DISPATCH_IO_STRICT_INTERVAL Enqueue I/O handlers at a channel's
546 * interval setting even if the amount of data ready to be delivered is inferior
547 * to the low water mark (or zero).
548 */
549#define DISPATCH_IO_STRICT_INTERVAL 0x1
550
551typedef unsigned long dispatch_io_interval_flags_t;
552
553/*!
554 * @function dispatch_io_set_interval
555 * Set a nanosecond interval at which I/O handlers are to be enqueued on the
556 * I/O channel for all operations.
557 *
558 * This allows an application to receive periodic feedback on the progress of
559 * read and write operations, e.g. for the purposes of displaying progress bars.
560 *
561 * If the amount of data ready to be delivered to an I/O handler at the interval
562 * is inferior to the channel low water mark, the handler will only be enqueued
563 * if the DISPATCH_IO_STRICT_INTERVAL flag is set.
564 *
565 * Note that the system may defer enqueueing interval I/O handlers by a small
566 * unspecified amount of leeway in order to align with other system activity for
567 * improved system performance or power consumption.
568 *
569 * @param channel The dispatch I/O channel on which to set the policy.
570 * @param interval The interval in nanoseconds at which delivery of the I/O
571 * handler is desired.
572 * @param flags Flags indicating desired data delivery behavior at
573 * interval time.
574 */
575__OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0)
576DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
577void
578dispatch_io_set_interval(dispatch_io_t channel,
579 uint64_t interval,
580 dispatch_io_interval_flags_t flags);
581
582#endif /* __BLOCKS__ */
583
584__END_DECLS
585
586#endif /* __DISPATCH_IO__ */