Line data Source code
1 : /*
2 : * Copyright (c) 2008-2014 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_QUEUE__
22 : #define __DISPATCH_QUEUE__
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 : #if __has_include(<sys/qos.h>)
30 : #include <sys/qos.h>
31 : #endif
32 :
33 : DISPATCH_ASSUME_NONNULL_BEGIN
34 :
35 : /*!
36 : * @header
37 : *
38 : * Dispatch is an abstract model for expressing concurrency via simple but
39 : * powerful API.
40 : *
41 : * At the core, dispatch provides serial FIFO queues to which blocks may be
42 : * submitted. Blocks submitted to these dispatch queues are invoked on a pool
43 : * of threads fully managed by the system. No guarantee is made regarding
44 : * which thread a block will be invoked on; however, it is guaranteed that only
45 : * one block submitted to the FIFO dispatch queue will be invoked at a time.
46 : *
47 : * When multiple queues have blocks to be processed, the system is free to
48 : * allocate additional threads to invoke the blocks concurrently. When the
49 : * queues become empty, these threads are automatically released.
50 : */
51 :
52 : /*!
53 : * @typedef dispatch_queue_t
54 : *
55 : * @abstract
56 : * Dispatch queues invoke workitems submitted to them.
57 : *
58 : * @discussion
59 : * Dispatch queues come in many flavors, the most common one being the dispatch
60 : * serial queue (See dispatch_queue_serial_t).
61 : *
62 : * The system manages a pool of threads which process dispatch queues and invoke
63 : * workitems submitted to them.
64 : *
65 : * Conceptually a dispatch queue may have its own thread of execution, and
66 : * interaction between queues is highly asynchronous.
67 : *
68 : * Dispatch queues are reference counted via calls to dispatch_retain() and
69 : * dispatch_release(). Pending workitems submitted to a queue also hold a
70 : * reference to the queue until they have finished. Once all references to a
71 : * queue have been released, the queue will be deallocated by the system.
72 : */
73 : DISPATCH_DECL(dispatch_queue);
74 :
75 : /*!
76 : * @typedef dispatch_queue_global_t
77 : *
78 : * @abstract
79 : * Dispatch global concurrent queues are an abstraction around the system thread
80 : * pool which invokes workitems that are submitted to dispatch queues.
81 : *
82 : * @discussion
83 : * Dispatch global concurrent queues provide buckets of priorities on top of the
84 : * thread pool the system manages. The system will decide how many threads
85 : * to allocate to this pool depending on demand and system load. In particular,
86 : * the system tries to maintain a good level of concurrency for this resource,
87 : * and will create new threads when too many existing worker threads block in
88 : * system calls.
89 : *
90 : * The global concurrent queues are a shared resource and as such it is the
91 : * responsiblity of every user of this resource to not submit an unbounded
92 : * amount of work to this pool, especially work that may block, as this can
93 : * cause the system to spawn very large numbers of threads (aka. thread
94 : * explosion).
95 : *
96 : * Work items submitted to the global concurrent queues have no ordering
97 : * guarantee with respect to the order of submission, and workitems submitted
98 : * to these queues may be invoked concurrently.
99 : *
100 : * Dispatch global concurrent queues are well-known global objects that are
101 : * returned by dispatch_get_global_queue(). These objects cannot be modified.
102 : * Calls to dispatch_suspend(), dispatch_resume(), dispatch_set_context(), etc.,
103 : * will have no effect when used with queues of this type.
104 : */
105 : DISPATCH_DECL_SUBCLASS(dispatch_queue_global, dispatch_queue);
106 :
107 : /*!
108 : * @typedef dispatch_queue_serial_t
109 : *
110 : * @abstract
111 : * Dispatch serial queues invoke workitems submitted to them serially in FIFO
112 : * order.
113 : *
114 : * @discussion
115 : * Dispatch serial queues are lightweight objects to which workitems may be
116 : * submitted to be invoked in FIFO order. A serial queue will only invoke one
117 : * workitem at a time, but independent serial queues may each invoke their work
118 : * items concurrently with respect to each other.
119 : *
120 : * Serial queues can target each other (See dispatch_set_target_queue()). The
121 : * serial queue at the bottom of a queue hierarchy provides an exclusion
122 : * context: at most one workitem submitted to any of the queues in such
123 : * a hiearchy will run at any given time.
124 : *
125 : * Such hierarchies provide a natural construct to organize an application
126 : * subsystem around.
127 : *
128 : * Serial queues are created by passing a dispatch queue attribute derived from
129 : * DISPATCH_QUEUE_SERIAL to dispatch_queue_create_with_target().
130 : */
131 : DISPATCH_DECL_SUBCLASS(dispatch_queue_serial, dispatch_queue);
132 :
133 : /*!
134 : * @typedef dispatch_queue_main_t
135 : *
136 : * @abstract
137 : * The type of the default queue that is bound to the main thread.
138 : *
139 : * @discussion
140 : * The main queue is a serial queue (See dispatch_queue_serial_t) which is bound
141 : * to the main thread of an application.
142 : *
143 : * In order to invoke workitems submitted to the main queue, the application
144 : * must call dispatch_main(), NSApplicationMain(), or use a CFRunLoop on the
145 : * main thread.
146 : *
147 : * The main queue is a well known global object that is made automatically on
148 : * behalf of the main thread during process initialization and is returned by
149 : * dispatch_get_main_queue(). This object cannot be modified. Calls to
150 : * dispatch_suspend(), dispatch_resume(), dispatch_set_context(), etc., will
151 : * have no effect when used on the main queue.
152 : */
153 : DISPATCH_DECL_SUBCLASS(dispatch_queue_main, dispatch_queue_serial);
154 :
155 : /*!
156 : * @typedef dispatch_queue_concurrent_t
157 : *
158 : * @abstract
159 : * Dispatch concurrent queues invoke workitems submitted to them concurrently,
160 : * and admit a notion of barrier workitems.
161 : *
162 : * @discussion
163 : * Dispatch concurrent queues are lightweight objects to which regular and
164 : * barrier workitems may be submited. Barrier workitems are invoked in
165 : * exclusion of any other kind of workitem in FIFO order.
166 : *
167 : * Regular workitems can be invoked concurrently for the same concurrent queue,
168 : * in any order. However, regular workitems will not be invoked before any
169 : * barrier workitem submited ahead of them has been invoked.
170 : *
171 : * In other words, if a serial queue is equivalent to a mutex in the Dispatch
172 : * world, a concurrent queue is equivalent to a reader-writer lock, where
173 : * regular items are readers and barriers are writers.
174 : *
175 : * Concurrent queues are created by passing a dispatch queue attribute derived
176 : * from DISPATCH_QUEUE_CONCURRENT to dispatch_queue_create_with_target().
177 : *
178 : * Caveat:
179 : * Dispatch concurrent queues at this time do not implement priority inversion
180 : * avoidance when lower priority regular workitems (readers) are being invoked
181 : * and are preventing a higher priority barrier (writer) from being invoked.
182 : */
183 : DISPATCH_DECL_SUBCLASS(dispatch_queue_concurrent, dispatch_queue);
184 :
185 : __BEGIN_DECLS
186 :
187 : /*!
188 : * @function dispatch_async
189 : *
190 : * @abstract
191 : * Submits a block for asynchronous execution on a dispatch queue.
192 : *
193 : * @discussion
194 : * The dispatch_async() function is the fundamental mechanism for submitting
195 : * blocks to a dispatch queue.
196 : *
197 : * Calls to dispatch_async() always return immediately after the block has
198 : * been submitted, and never wait for the block to be invoked.
199 : *
200 : * The target queue determines whether the block will be invoked serially or
201 : * concurrently with respect to other blocks submitted to that same queue.
202 : * Serial queues are processed concurrently with respect to each other.
203 : *
204 : * @param queue
205 : * The target dispatch queue to which the block is submitted.
206 : * The system will hold a reference on the target queue until the block
207 : * has finished.
208 : * The result of passing NULL in this parameter is undefined.
209 : *
210 : * @param block
211 : * The block to submit to the target dispatch queue. This function performs
212 : * Block_copy() and Block_release() on behalf of callers.
213 : * The result of passing NULL in this parameter is undefined.
214 : */
215 : #ifdef __BLOCKS__
216 : API_AVAILABLE(macos(10.6), ios(4.0))
217 : DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
218 : void
219 : dispatch_async(dispatch_queue_t queue, dispatch_block_t block);
220 : #endif
221 :
222 : /*!
223 : * @function dispatch_async_f
224 : *
225 : * @abstract
226 : * Submits a function for asynchronous execution on a dispatch queue.
227 : *
228 : * @discussion
229 : * See dispatch_async() for details.
230 : *
231 : * @param queue
232 : * The target dispatch queue to which the function is submitted.
233 : * The system will hold a reference on the target queue until the function
234 : * has returned.
235 : * The result of passing NULL in this parameter is undefined.
236 : *
237 : * @param context
238 : * The application-defined context parameter to pass to the function.
239 : *
240 : * @param work
241 : * The application-defined function to invoke on the target queue. The first
242 : * parameter passed to this function is the context provided to
243 : * dispatch_async_f().
244 : * The result of passing NULL in this parameter is undefined.
245 : */
246 : API_AVAILABLE(macos(10.6), ios(4.0))
247 : DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW
248 : void
249 : dispatch_async_f(dispatch_queue_t queue,
250 : void *_Nullable context, dispatch_function_t work);
251 :
252 : /*!
253 : * @function dispatch_sync
254 : *
255 : * @abstract
256 : * Submits a block for synchronous execution on a dispatch queue.
257 : *
258 : * @discussion
259 : * Submits a workitem to a dispatch queue like dispatch_async(), however
260 : * dispatch_sync() will not return until the workitem has finished.
261 : *
262 : * Work items submitted to a queue with dispatch_sync() do not observe certain
263 : * queue attributes of that queue when invoked (such as autorelease frequency
264 : * and QOS class).
265 : *
266 : * Calls to dispatch_sync() targeting the current queue will result
267 : * in dead-lock. Use of dispatch_sync() is also subject to the same
268 : * multi-party dead-lock problems that may result from the use of a mutex.
269 : * Use of dispatch_async() is preferred.
270 : *
271 : * Unlike dispatch_async(), no retain is performed on the target queue. Because
272 : * calls to this function are synchronous, the dispatch_sync() "borrows" the
273 : * reference of the caller.
274 : *
275 : * As an optimization, dispatch_sync() invokes the workitem on the thread which
276 : * submitted the workitem, except when the passed queue is the main queue or
277 : * a queue targetting it (See dispatch_queue_main_t,
278 : * dispatch_set_target_queue()).
279 : *
280 : * @param queue
281 : * The target dispatch queue to which the block is submitted.
282 : * The result of passing NULL in this parameter is undefined.
283 : *
284 : * @param block
285 : * The block to be invoked on the target dispatch queue.
286 : * The result of passing NULL in this parameter is undefined.
287 : */
288 : #ifdef __BLOCKS__
289 : API_AVAILABLE(macos(10.6), ios(4.0))
290 : DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
291 : void
292 : dispatch_sync(dispatch_queue_t queue, DISPATCH_NOESCAPE dispatch_block_t block);
293 : #endif
294 :
295 : /*!
296 : * @function dispatch_sync_f
297 : *
298 : * @abstract
299 : * Submits a function for synchronous execution on a dispatch queue.
300 : *
301 : * @discussion
302 : * See dispatch_sync() for details.
303 : *
304 : * @param queue
305 : * The target dispatch queue to which the function is submitted.
306 : * The result of passing NULL in this parameter is undefined.
307 : *
308 : * @param context
309 : * The application-defined context parameter to pass to the function.
310 : *
311 : * @param work
312 : * The application-defined function to invoke on the target queue. The first
313 : * parameter passed to this function is the context provided to
314 : * dispatch_sync_f().
315 : * The result of passing NULL in this parameter is undefined.
316 : */
317 : API_AVAILABLE(macos(10.6), ios(4.0))
318 : DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW
319 : void
320 : dispatch_sync_f(dispatch_queue_t queue,
321 : void *_Nullable context, dispatch_function_t work);
322 :
323 :
324 : #if defined(__APPLE__) && \
325 : (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && \
326 : __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_7_0) || \
327 : (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
328 : __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_9)
329 : #define DISPATCH_APPLY_AUTO_AVAILABLE 0
330 : #define DISPATCH_APPLY_QUEUE_ARG_NULLABILITY _Nonnull
331 : #else
332 : #define DISPATCH_APPLY_AUTO_AVAILABLE 1
333 : #define DISPATCH_APPLY_QUEUE_ARG_NULLABILITY _Nullable
334 : #endif
335 :
336 : /*!
337 : * @constant DISPATCH_APPLY_AUTO
338 : *
339 : * @abstract
340 : * Constant to pass to dispatch_apply() or dispatch_apply_f() to request that
341 : * the system automatically use worker threads that match the configuration of
342 : * the current thread as closely as possible.
343 : *
344 : * @discussion
345 : * When submitting a block for parallel invocation, passing this constant as the
346 : * queue argument will automatically use the global concurrent queue that
347 : * matches the Quality of Service of the caller most closely.
348 : *
349 : * No assumptions should be made about which global concurrent queue will
350 : * actually be used.
351 : *
352 : * Using this constant deploys backward to macOS 10.9, iOS 7.0 and any tvOS or
353 : * watchOS version.
354 : */
355 : #if DISPATCH_APPLY_AUTO_AVAILABLE
356 : #define DISPATCH_APPLY_AUTO ((dispatch_queue_t _Nonnull)0)
357 : #endif
358 :
359 : /*!
360 : * @function dispatch_apply
361 : *
362 : * @abstract
363 : * Submits a block to a dispatch queue for parallel invocation.
364 : *
365 : * @discussion
366 : * Submits a block to a dispatch queue for parallel invocation. This function
367 : * waits for the task block to complete before returning. If the specified queue
368 : * is concurrent, the block may be invoked concurrently, and it must therefore
369 : * be reentrant safe.
370 : *
371 : * Each invocation of the block will be passed the current index of iteration.
372 : *
373 : * @param iterations
374 : * The number of iterations to perform.
375 : *
376 : * @param queue
377 : * The dispatch queue to which the block is submitted.
378 : * The preferred value to pass is DISPATCH_APPLY_AUTO to automatically use
379 : * a queue appropriate for the calling thread.
380 : *
381 : * @param block
382 : * The block to be invoked the specified number of iterations.
383 : * The result of passing NULL in this parameter is undefined.
384 : */
385 : #ifdef __BLOCKS__
386 : API_AVAILABLE(macos(10.6), ios(4.0))
387 : DISPATCH_EXPORT DISPATCH_NONNULL3 DISPATCH_NOTHROW
388 : void
389 : dispatch_apply(size_t iterations,
390 : dispatch_queue_t DISPATCH_APPLY_QUEUE_ARG_NULLABILITY queue,
391 : DISPATCH_NOESCAPE void (^block)(size_t));
392 : #endif
393 :
394 : /*!
395 : * @function dispatch_apply_f
396 : *
397 : * @abstract
398 : * Submits a function to a dispatch queue for parallel invocation.
399 : *
400 : * @discussion
401 : * See dispatch_apply() for details.
402 : *
403 : * @param iterations
404 : * The number of iterations to perform.
405 : *
406 : * @param queue
407 : * The dispatch queue to which the function is submitted.
408 : * The preferred value to pass is DISPATCH_APPLY_AUTO to automatically use
409 : * a queue appropriate for the calling thread.
410 : *
411 : * @param context
412 : * The application-defined context parameter to pass to the function.
413 : *
414 : * @param work
415 : * The application-defined function to invoke on the specified queue. The first
416 : * parameter passed to this function is the context provided to
417 : * dispatch_apply_f(). The second parameter passed to this function is the
418 : * current index of iteration.
419 : * The result of passing NULL in this parameter is undefined.
420 : */
421 : API_AVAILABLE(macos(10.6), ios(4.0))
422 : DISPATCH_EXPORT DISPATCH_NONNULL4 DISPATCH_NOTHROW
423 : void
424 : dispatch_apply_f(size_t iterations,
425 : dispatch_queue_t DISPATCH_APPLY_QUEUE_ARG_NULLABILITY queue,
426 : void *_Nullable context, void (*work)(void *_Nullable, size_t));
427 :
428 : /*!
429 : * @function dispatch_get_current_queue
430 : *
431 : * @abstract
432 : * Returns the queue on which the currently executing block is running.
433 : *
434 : * @discussion
435 : * Returns the queue on which the currently executing block is running.
436 : *
437 : * When dispatch_get_current_queue() is called outside of the context of a
438 : * submitted block, it will return the default concurrent queue.
439 : *
440 : * Recommended for debugging and logging purposes only:
441 : * The code must not make any assumptions about the queue returned, unless it
442 : * is one of the global queues or a queue the code has itself created.
443 : * The code must not assume that synchronous execution onto a queue is safe
444 : * from deadlock if that queue is not the one returned by
445 : * dispatch_get_current_queue().
446 : *
447 : * When dispatch_get_current_queue() is called on the main thread, it may
448 : * or may not return the same value as dispatch_get_main_queue(). Comparing
449 : * the two is not a valid way to test whether code is executing on the
450 : * main thread (see dispatch_assert_queue() and dispatch_assert_queue_not()).
451 : *
452 : * This function is deprecated and will be removed in a future release.
453 : *
454 : * @result
455 : * Returns the current queue.
456 : */
457 : API_DEPRECATED("unsupported interface", macos(10.6,10.9), ios(4.0,6.0))
458 : DISPATCH_EXPORT DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_NOTHROW
459 : dispatch_queue_t
460 : dispatch_get_current_queue(void);
461 :
462 : API_AVAILABLE(macos(10.6), ios(4.0))
463 : DISPATCH_EXPORT
464 : struct dispatch_queue_s _dispatch_main_q;
465 :
466 : /*!
467 : * @function dispatch_get_main_queue
468 : *
469 : * @abstract
470 : * Returns the default queue that is bound to the main thread.
471 : *
472 : * @discussion
473 : * In order to invoke blocks submitted to the main queue, the application must
474 : * call dispatch_main(), NSApplicationMain(), or use a CFRunLoop on the main
475 : * thread.
476 : *
477 : * The main queue is meant to be used in application context to interact with
478 : * the main thread and the main runloop.
479 : *
480 : * Because the main queue doesn't behave entirely like a regular serial queue,
481 : * it may have unwanted side-effects when used in processes that are not UI apps
482 : * (daemons). For such processes, the main queue should be avoided.
483 : *
484 : * @see dispatch_queue_main_t
485 : *
486 : * @result
487 : * Returns the main queue. This queue is created automatically on behalf of
488 : * the main thread before main() is called.
489 : */
490 : DISPATCH_INLINE DISPATCH_ALWAYS_INLINE DISPATCH_CONST DISPATCH_NOTHROW
491 : dispatch_queue_main_t
492 : dispatch_get_main_queue(void)
493 : {
494 512 : return DISPATCH_GLOBAL_OBJECT(dispatch_queue_main_t, _dispatch_main_q);
495 : }
496 :
497 : /*!
498 : * @typedef dispatch_queue_priority_t
499 : * Type of dispatch_queue_priority
500 : *
501 : * @constant DISPATCH_QUEUE_PRIORITY_HIGH
502 : * Items dispatched to the queue will run at high priority,
503 : * i.e. the queue will be scheduled for execution before
504 : * any default priority or low priority queue.
505 : *
506 : * @constant DISPATCH_QUEUE_PRIORITY_DEFAULT
507 : * Items dispatched to the queue will run at the default
508 : * priority, i.e. the queue will be scheduled for execution
509 : * after all high priority queues have been scheduled, but
510 : * before any low priority queues have been scheduled.
511 : *
512 : * @constant DISPATCH_QUEUE_PRIORITY_LOW
513 : * Items dispatched to the queue will run at low priority,
514 : * i.e. the queue will be scheduled for execution after all
515 : * default priority and high priority queues have been
516 : * scheduled.
517 : *
518 : * @constant DISPATCH_QUEUE_PRIORITY_BACKGROUND
519 : * Items dispatched to the queue will run at background priority, i.e. the queue
520 : * will be scheduled for execution after all higher priority queues have been
521 : * scheduled and the system will run items on this queue on a thread with
522 : * background status as per setpriority(2) (i.e. disk I/O is throttled and the
523 : * thread's scheduling priority is set to lowest value).
524 : */
525 : #define DISPATCH_QUEUE_PRIORITY_HIGH 2
526 : #define DISPATCH_QUEUE_PRIORITY_DEFAULT 0
527 : #define DISPATCH_QUEUE_PRIORITY_LOW (-2)
528 : #define DISPATCH_QUEUE_PRIORITY_BACKGROUND INT16_MIN
529 :
530 : typedef long dispatch_queue_priority_t;
531 :
532 : /*!
533 : * @typedef dispatch_qos_class_t
534 : * Alias for qos_class_t type.
535 : */
536 : #if __has_include(<sys/qos.h>)
537 : typedef qos_class_t dispatch_qos_class_t;
538 : #else
539 : typedef unsigned int dispatch_qos_class_t;
540 : #endif
541 :
542 : /*!
543 : * @function dispatch_get_global_queue
544 : *
545 : * @abstract
546 : * Returns a well-known global concurrent queue of a given quality of service
547 : * class.
548 : *
549 : * @discussion
550 : * See dispatch_queue_global_t.
551 : *
552 : * @param identifier
553 : * A quality of service class defined in qos_class_t or a priority defined in
554 : * dispatch_queue_priority_t.
555 : *
556 : * It is recommended to use quality of service class values to identify the
557 : * well-known global concurrent queues:
558 : * - QOS_CLASS_USER_INTERACTIVE
559 : * - QOS_CLASS_USER_INITIATED
560 : * - QOS_CLASS_DEFAULT
561 : * - QOS_CLASS_UTILITY
562 : * - QOS_CLASS_BACKGROUND
563 : *
564 : * The global concurrent queues may still be identified by their priority,
565 : * which map to the following QOS classes:
566 : * - DISPATCH_QUEUE_PRIORITY_HIGH: QOS_CLASS_USER_INITIATED
567 : * - DISPATCH_QUEUE_PRIORITY_DEFAULT: QOS_CLASS_DEFAULT
568 : * - DISPATCH_QUEUE_PRIORITY_LOW: QOS_CLASS_UTILITY
569 : * - DISPATCH_QUEUE_PRIORITY_BACKGROUND: QOS_CLASS_BACKGROUND
570 : *
571 : * @param flags
572 : * Reserved for future use. Passing any value other than zero may result in
573 : * a NULL return value.
574 : *
575 : * @result
576 : * Returns the requested global queue or NULL if the requested global queue
577 : * does not exist.
578 : */
579 : API_AVAILABLE(macos(10.6), ios(4.0))
580 : DISPATCH_EXPORT DISPATCH_CONST DISPATCH_WARN_RESULT DISPATCH_NOTHROW
581 : dispatch_queue_global_t
582 : dispatch_get_global_queue(long identifier, unsigned long flags);
583 :
584 : /*!
585 : * @typedef dispatch_queue_attr_t
586 : *
587 : * @abstract
588 : * Attribute for dispatch queues.
589 : */
590 : DISPATCH_DECL(dispatch_queue_attr);
591 :
592 : /*!
593 : * @const DISPATCH_QUEUE_SERIAL
594 : *
595 : * @discussion
596 : * An attribute that can be used to create a dispatch queue that invokes blocks
597 : * serially in FIFO order.
598 : *
599 : * See dispatch_queue_serial_t.
600 : */
601 : #define DISPATCH_QUEUE_SERIAL NULL
602 :
603 : /*!
604 : * @const DISPATCH_QUEUE_SERIAL_INACTIVE
605 : *
606 : * @discussion
607 : * An attribute that can be used to create a dispatch queue that invokes blocks
608 : * serially in FIFO order, and that is initially inactive.
609 : *
610 : * See dispatch_queue_attr_make_initially_inactive().
611 : */
612 : #define DISPATCH_QUEUE_SERIAL_INACTIVE \
613 : dispatch_queue_attr_make_initially_inactive(DISPATCH_QUEUE_SERIAL)
614 :
615 : /*!
616 : * @const DISPATCH_QUEUE_CONCURRENT
617 : *
618 : * @discussion
619 : * An attribute that can be used to create a dispatch queue that may invoke
620 : * blocks concurrently and supports barrier blocks submitted with the dispatch
621 : * barrier API.
622 : *
623 : * See dispatch_queue_concurrent_t.
624 : */
625 : #define DISPATCH_QUEUE_CONCURRENT \
626 : DISPATCH_GLOBAL_OBJECT(dispatch_queue_attr_t, \
627 : _dispatch_queue_attr_concurrent)
628 : API_AVAILABLE(macos(10.7), ios(4.3))
629 : DISPATCH_EXPORT
630 : struct dispatch_queue_attr_s _dispatch_queue_attr_concurrent;
631 :
632 : /*!
633 : * @const DISPATCH_QUEUE_CONCURRENT_INACTIVE
634 : *
635 : * @discussion
636 : * An attribute that can be used to create a dispatch queue that may invoke
637 : * blocks concurrently and supports barrier blocks submitted with the dispatch
638 : * barrier API, and that is initially inactive.
639 : *
640 : * See dispatch_queue_attr_make_initially_inactive().
641 : */
642 : #define DISPATCH_QUEUE_CONCURRENT_INACTIVE \
643 : dispatch_queue_attr_make_initially_inactive(DISPATCH_QUEUE_CONCURRENT)
644 :
645 : /*!
646 : * @function dispatch_queue_attr_make_initially_inactive
647 : *
648 : * @abstract
649 : * Returns an attribute value which may be provided to dispatch_queue_create()
650 : * or dispatch_queue_create_with_target(), in order to make the created queue
651 : * initially inactive.
652 : *
653 : * @discussion
654 : * Dispatch queues may be created in an inactive state. Queues in this state
655 : * have to be activated before any blocks associated with them will be invoked.
656 : *
657 : * A queue in inactive state cannot be deallocated, dispatch_activate() must be
658 : * called before the last reference to a queue created with this attribute is
659 : * released.
660 : *
661 : * The target queue of a queue in inactive state can be changed using
662 : * dispatch_set_target_queue(). Change of target queue is no longer permitted
663 : * once an initially inactive queue has been activated.
664 : *
665 : * @param attr
666 : * A queue attribute value to be combined with the initially inactive attribute.
667 : *
668 : * @return
669 : * Returns an attribute value which may be provided to dispatch_queue_create()
670 : * and dispatch_queue_create_with_target().
671 : * The new value combines the attributes specified by the 'attr' parameter with
672 : * the initially inactive attribute.
673 : */
674 : API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
675 : DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_PURE DISPATCH_NOTHROW
676 : dispatch_queue_attr_t
677 : dispatch_queue_attr_make_initially_inactive(
678 : dispatch_queue_attr_t _Nullable attr);
679 :
680 : /*!
681 : * @const DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL
682 : *
683 : * @discussion
684 : * A dispatch queue created with this attribute invokes blocks serially in FIFO
685 : * order, and surrounds execution of any block submitted asynchronously to it
686 : * with the equivalent of a individual Objective-C <code>@autoreleasepool</code>
687 : * scope.
688 : *
689 : * See dispatch_queue_attr_make_with_autorelease_frequency().
690 : */
691 : #define DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL \
692 : dispatch_queue_attr_make_with_autorelease_frequency(\
693 : DISPATCH_QUEUE_SERIAL, DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM)
694 :
695 : /*!
696 : * @const DISPATCH_QUEUE_CONCURRENT_WITH_AUTORELEASE_POOL
697 : *
698 : * @discussion
699 : * A dispatch queue created with this attribute may invokes blocks concurrently
700 : * and supports barrier blocks submitted with the dispatch barrier API. It also
701 : * surrounds execution of any block submitted asynchronously to it with the
702 : * equivalent of a individual Objective-C <code>@autoreleasepool</code>
703 : *
704 : * See dispatch_queue_attr_make_with_autorelease_frequency().
705 : */
706 : #define DISPATCH_QUEUE_CONCURRENT_WITH_AUTORELEASE_POOL \
707 : dispatch_queue_attr_make_with_autorelease_frequency(\
708 : DISPATCH_QUEUE_CONCURRENT, DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM)
709 :
710 : /*!
711 : * @typedef dispatch_autorelease_frequency_t
712 : * Values to pass to the dispatch_queue_attr_make_with_autorelease_frequency()
713 : * function.
714 : *
715 : * @const DISPATCH_AUTORELEASE_FREQUENCY_INHERIT
716 : * Dispatch queues with this autorelease frequency inherit the behavior from
717 : * their target queue. This is the default behavior for manually created queues.
718 : *
719 : * @const DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM
720 : * Dispatch queues with this autorelease frequency push and pop an autorelease
721 : * pool around the execution of every block that was submitted to it
722 : * asynchronously.
723 : * @see dispatch_queue_attr_make_with_autorelease_frequency().
724 : *
725 : * @const DISPATCH_AUTORELEASE_FREQUENCY_NEVER
726 : * Dispatch queues with this autorelease frequency never set up an individual
727 : * autorelease pool around the execution of a block that is submitted to it
728 : * asynchronously. This is the behavior of the global concurrent queues.
729 : */
730 : DISPATCH_ENUM(dispatch_autorelease_frequency, unsigned long,
731 : DISPATCH_AUTORELEASE_FREQUENCY_INHERIT DISPATCH_ENUM_API_AVAILABLE(
732 : macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) = 0,
733 : DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM DISPATCH_ENUM_API_AVAILABLE(
734 : macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) = 1,
735 : DISPATCH_AUTORELEASE_FREQUENCY_NEVER DISPATCH_ENUM_API_AVAILABLE(
736 : macos(10.12), ios(10.0), tvos(10.0), watchos(3.0)) = 2,
737 : );
738 :
739 : /*!
740 : * @function dispatch_queue_attr_make_with_autorelease_frequency
741 : *
742 : * @abstract
743 : * Returns a dispatch queue attribute value with the autorelease frequency
744 : * set to the specified value.
745 : *
746 : * @discussion
747 : * When a queue uses the per-workitem autorelease frequency (either directly
748 : * or inherithed from its target queue), any block submitted asynchronously to
749 : * this queue (via dispatch_async(), dispatch_barrier_async(),
750 : * dispatch_group_notify(), etc...) is executed as if surrounded by a individual
751 : * Objective-C <code>@autoreleasepool</code> scope.
752 : *
753 : * Autorelease frequency has no effect on blocks that are submitted
754 : * synchronously to a queue (via dispatch_sync(), dispatch_barrier_sync()).
755 : *
756 : * The global concurrent queues have the DISPATCH_AUTORELEASE_FREQUENCY_NEVER
757 : * behavior. Manually created dispatch queues use
758 : * DISPATCH_AUTORELEASE_FREQUENCY_INHERIT by default.
759 : *
760 : * Queues created with this attribute cannot change target queues after having
761 : * been activated. See dispatch_set_target_queue() and dispatch_activate().
762 : *
763 : * @param attr
764 : * A queue attribute value to be combined with the specified autorelease
765 : * frequency or NULL.
766 : *
767 : * @param frequency
768 : * The requested autorelease frequency.
769 : *
770 : * @return
771 : * Returns an attribute value which may be provided to dispatch_queue_create()
772 : * or NULL if an invalid autorelease frequency was requested.
773 : * This new value combines the attributes specified by the 'attr' parameter and
774 : * the chosen autorelease frequency.
775 : */
776 : API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
777 : DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_PURE DISPATCH_NOTHROW
778 : dispatch_queue_attr_t
779 : dispatch_queue_attr_make_with_autorelease_frequency(
780 : dispatch_queue_attr_t _Nullable attr,
781 : dispatch_autorelease_frequency_t frequency);
782 :
783 : /*!
784 : * @function dispatch_queue_attr_make_with_qos_class
785 : *
786 : * @abstract
787 : * Returns an attribute value which may be provided to dispatch_queue_create()
788 : * or dispatch_queue_create_with_target(), in order to assign a QOS class and
789 : * relative priority to the queue.
790 : *
791 : * @discussion
792 : * When specified in this manner, the QOS class and relative priority take
793 : * precedence over those inherited from the dispatch queue's target queue (if
794 : * any) as long that does not result in a lower QOS class and relative priority.
795 : *
796 : * The global queue priorities map to the following QOS classes:
797 : * - DISPATCH_QUEUE_PRIORITY_HIGH: QOS_CLASS_USER_INITIATED
798 : * - DISPATCH_QUEUE_PRIORITY_DEFAULT: QOS_CLASS_DEFAULT
799 : * - DISPATCH_QUEUE_PRIORITY_LOW: QOS_CLASS_UTILITY
800 : * - DISPATCH_QUEUE_PRIORITY_BACKGROUND: QOS_CLASS_BACKGROUND
801 : *
802 : * Example:
803 : * <code>
804 : * dispatch_queue_t queue;
805 : * dispatch_queue_attr_t attr;
806 : * attr = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL,
807 : * QOS_CLASS_UTILITY, 0);
808 : * queue = dispatch_queue_create("com.example.myqueue", attr);
809 : * </code>
810 : *
811 : * The QOS class and relative priority set this way on a queue have no effect on
812 : * blocks that are submitted synchronously to a queue (via dispatch_sync(),
813 : * dispatch_barrier_sync()).
814 : *
815 : * @param attr
816 : * A queue attribute value to be combined with the QOS class, or NULL.
817 : *
818 : * @param qos_class
819 : * A QOS class value:
820 : * - QOS_CLASS_USER_INTERACTIVE
821 : * - QOS_CLASS_USER_INITIATED
822 : * - QOS_CLASS_DEFAULT
823 : * - QOS_CLASS_UTILITY
824 : * - QOS_CLASS_BACKGROUND
825 : * Passing any other value results in NULL being returned.
826 : *
827 : * @param relative_priority
828 : * A relative priority within the QOS class. This value is a negative
829 : * offset from the maximum supported scheduler priority for the given class.
830 : * Passing a value greater than zero or less than QOS_MIN_RELATIVE_PRIORITY
831 : * results in NULL being returned.
832 : *
833 : * @return
834 : * Returns an attribute value which may be provided to dispatch_queue_create()
835 : * and dispatch_queue_create_with_target(), or NULL if an invalid QOS class was
836 : * requested.
837 : * The new value combines the attributes specified by the 'attr' parameter and
838 : * the new QOS class and relative priority.
839 : */
840 : API_AVAILABLE(macos(10.10), ios(8.0))
841 : DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_PURE DISPATCH_NOTHROW
842 : dispatch_queue_attr_t
843 : dispatch_queue_attr_make_with_qos_class(dispatch_queue_attr_t _Nullable attr,
844 : dispatch_qos_class_t qos_class, int relative_priority);
845 :
846 : /*!
847 : * @const DISPATCH_TARGET_QUEUE_DEFAULT
848 : * @discussion Constant to pass to the dispatch_queue_create_with_target(),
849 : * dispatch_set_target_queue() and dispatch_source_create() functions to
850 : * indicate that the default target queue for the object type in question
851 : * should be used.
852 : */
853 : #define DISPATCH_TARGET_QUEUE_DEFAULT NULL
854 :
855 : /*!
856 : * @function dispatch_queue_create_with_target
857 : *
858 : * @abstract
859 : * Creates a new dispatch queue with a specified target queue.
860 : *
861 : * @discussion
862 : * Dispatch queues created with the DISPATCH_QUEUE_SERIAL or a NULL attribute
863 : * invoke blocks serially in FIFO order.
864 : *
865 : * Dispatch queues created with the DISPATCH_QUEUE_CONCURRENT attribute may
866 : * invoke blocks concurrently (similarly to the global concurrent queues, but
867 : * potentially with more overhead), and support barrier blocks submitted with
868 : * the dispatch barrier API, which e.g. enables the implementation of efficient
869 : * reader-writer schemes.
870 : *
871 : * When a dispatch queue is no longer needed, it should be released with
872 : * dispatch_release(). Note that any pending blocks submitted asynchronously to
873 : * a queue will hold a reference to that queue. Therefore a queue will not be
874 : * deallocated until all pending blocks have finished.
875 : *
876 : * When using a dispatch queue attribute @a attr specifying a QoS class (derived
877 : * from the result of dispatch_queue_attr_make_with_qos_class()), passing the
878 : * result of dispatch_get_global_queue() in @a target will ignore the QoS class
879 : * of that global queue and will use the global queue with the QoS class
880 : * specified by attr instead.
881 : *
882 : * Queues created with dispatch_queue_create_with_target() cannot have their
883 : * target queue changed, unless created inactive (See
884 : * dispatch_queue_attr_make_initially_inactive()), in which case the target
885 : * queue can be changed until the newly created queue is activated with
886 : * dispatch_activate().
887 : *
888 : * @param label
889 : * A string label to attach to the queue.
890 : * This parameter is optional and may be NULL.
891 : *
892 : * @param attr
893 : * A predefined attribute such as DISPATCH_QUEUE_SERIAL,
894 : * DISPATCH_QUEUE_CONCURRENT, or the result of a call to
895 : * a dispatch_queue_attr_make_with_* function.
896 : *
897 : * @param target
898 : * The target queue for the newly created queue. The target queue is retained.
899 : * If this parameter is DISPATCH_TARGET_QUEUE_DEFAULT, sets the queue's target
900 : * queue to the default target queue for the given queue type.
901 : *
902 : * @result
903 : * The newly created dispatch queue.
904 : */
905 : API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
906 : DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
907 : DISPATCH_NOTHROW
908 : dispatch_queue_t
909 : dispatch_queue_create_with_target(const char *_Nullable label,
910 : dispatch_queue_attr_t _Nullable attr, dispatch_queue_t _Nullable target)
911 : DISPATCH_ALIAS_V2(dispatch_queue_create_with_target);
912 :
913 : /*!
914 : * @function dispatch_queue_create
915 : *
916 : * @abstract
917 : * Creates a new dispatch queue to which blocks may be submitted.
918 : *
919 : * @discussion
920 : * Dispatch queues created with the DISPATCH_QUEUE_SERIAL or a NULL attribute
921 : * invoke blocks serially in FIFO order.
922 : *
923 : * Dispatch queues created with the DISPATCH_QUEUE_CONCURRENT attribute may
924 : * invoke blocks concurrently (similarly to the global concurrent queues, but
925 : * potentially with more overhead), and support barrier blocks submitted with
926 : * the dispatch barrier API, which e.g. enables the implementation of efficient
927 : * reader-writer schemes.
928 : *
929 : * When a dispatch queue is no longer needed, it should be released with
930 : * dispatch_release(). Note that any pending blocks submitted asynchronously to
931 : * a queue will hold a reference to that queue. Therefore a queue will not be
932 : * deallocated until all pending blocks have finished.
933 : *
934 : * Passing the result of the dispatch_queue_attr_make_with_qos_class() function
935 : * to the attr parameter of this function allows a quality of service class and
936 : * relative priority to be specified for the newly created queue.
937 : * The quality of service class so specified takes precedence over the quality
938 : * of service class of the newly created dispatch queue's target queue (if any)
939 : * as long that does not result in a lower QOS class and relative priority.
940 : *
941 : * When no quality of service class is specified, the target queue of a newly
942 : * created dispatch queue is the default priority global concurrent queue.
943 : *
944 : * @param label
945 : * A string label to attach to the queue.
946 : * This parameter is optional and may be NULL.
947 : *
948 : * @param attr
949 : * A predefined attribute such as DISPATCH_QUEUE_SERIAL,
950 : * DISPATCH_QUEUE_CONCURRENT, or the result of a call to
951 : * a dispatch_queue_attr_make_with_* function.
952 : *
953 : * @result
954 : * The newly created dispatch queue.
955 : */
956 : API_AVAILABLE(macos(10.6), ios(4.0))
957 : DISPATCH_EXPORT DISPATCH_MALLOC DISPATCH_RETURNS_RETAINED DISPATCH_WARN_RESULT
958 : DISPATCH_NOTHROW
959 : dispatch_queue_t
960 : dispatch_queue_create(const char *_Nullable label,
961 : dispatch_queue_attr_t _Nullable attr);
962 :
963 : /*!
964 : * @const DISPATCH_CURRENT_QUEUE_LABEL
965 : * @discussion Constant to pass to the dispatch_queue_get_label() function to
966 : * retrieve the label of the current queue.
967 : */
968 : #define DISPATCH_CURRENT_QUEUE_LABEL NULL
969 :
970 : /*!
971 : * @function dispatch_queue_get_label
972 : *
973 : * @abstract
974 : * Returns the label of the given queue, as specified when the queue was
975 : * created, or the empty string if a NULL label was specified.
976 : *
977 : * Passing DISPATCH_CURRENT_QUEUE_LABEL will return the label of the current
978 : * queue.
979 : *
980 : * @param queue
981 : * The queue to query, or DISPATCH_CURRENT_QUEUE_LABEL.
982 : *
983 : * @result
984 : * The label of the queue.
985 : */
986 : API_AVAILABLE(macos(10.6), ios(4.0))
987 : DISPATCH_EXPORT DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_NOTHROW
988 : const char *
989 : dispatch_queue_get_label(dispatch_queue_t _Nullable queue);
990 :
991 : /*!
992 : * @function dispatch_queue_get_qos_class
993 : *
994 : * @abstract
995 : * Returns the QOS class and relative priority of the given queue.
996 : *
997 : * @discussion
998 : * If the given queue was created with an attribute value returned from
999 : * dispatch_queue_attr_make_with_qos_class(), this function returns the QOS
1000 : * class and relative priority specified at that time; for any other attribute
1001 : * value it returns a QOS class of QOS_CLASS_UNSPECIFIED and a relative
1002 : * priority of 0.
1003 : *
1004 : * If the given queue is one of the global queues, this function returns its
1005 : * assigned QOS class value as documented under dispatch_get_global_queue() and
1006 : * a relative priority of 0; in the case of the main queue it returns the QOS
1007 : * value provided by qos_class_main() and a relative priority of 0.
1008 : *
1009 : * @param queue
1010 : * The queue to query.
1011 : *
1012 : * @param relative_priority_ptr
1013 : * A pointer to an int variable to be filled with the relative priority offset
1014 : * within the QOS class, or NULL.
1015 : *
1016 : * @return
1017 : * A QOS class value:
1018 : * - QOS_CLASS_USER_INTERACTIVE
1019 : * - QOS_CLASS_USER_INITIATED
1020 : * - QOS_CLASS_DEFAULT
1021 : * - QOS_CLASS_UTILITY
1022 : * - QOS_CLASS_BACKGROUND
1023 : * - QOS_CLASS_UNSPECIFIED
1024 : */
1025 : API_AVAILABLE(macos(10.10), ios(8.0))
1026 : DISPATCH_EXPORT DISPATCH_WARN_RESULT DISPATCH_NONNULL1 DISPATCH_NOTHROW
1027 : dispatch_qos_class_t
1028 : dispatch_queue_get_qos_class(dispatch_queue_t queue,
1029 : int *_Nullable relative_priority_ptr);
1030 :
1031 : /*!
1032 : * @function dispatch_set_target_queue
1033 : *
1034 : * @abstract
1035 : * Sets the target queue for the given object.
1036 : *
1037 : * @discussion
1038 : * An object's target queue is responsible for processing the object.
1039 : *
1040 : * When no quality of service class and relative priority is specified for a
1041 : * dispatch queue at the time of creation, a dispatch queue's quality of service
1042 : * class is inherited from its target queue. The dispatch_get_global_queue()
1043 : * function may be used to obtain a target queue of a specific quality of
1044 : * service class, however the use of dispatch_queue_attr_make_with_qos_class()
1045 : * is recommended instead.
1046 : *
1047 : * Blocks submitted to a serial queue whose target queue is another serial
1048 : * queue will not be invoked concurrently with blocks submitted to the target
1049 : * queue or to any other queue with that same target queue.
1050 : *
1051 : * The result of introducing a cycle into the hierarchy of target queues is
1052 : * undefined.
1053 : *
1054 : * A dispatch source's target queue specifies where its event handler and
1055 : * cancellation handler blocks will be submitted.
1056 : *
1057 : * A dispatch I/O channel's target queue specifies where where its I/O
1058 : * operations are executed. If the channel's target queue's priority is set to
1059 : * DISPATCH_QUEUE_PRIORITY_BACKGROUND, then the I/O operations performed by
1060 : * dispatch_io_read() or dispatch_io_write() on that queue will be
1061 : * throttled when there is I/O contention.
1062 : *
1063 : * For all other dispatch object types, the only function of the target queue
1064 : * is to determine where an object's finalizer function is invoked.
1065 : *
1066 : * In general, changing the target queue of an object is an asynchronous
1067 : * operation that doesn't take effect immediately, and doesn't affect blocks
1068 : * already associated with the specified object.
1069 : *
1070 : * However, if an object is inactive at the time dispatch_set_target_queue() is
1071 : * called, then the target queue change takes effect immediately, and will
1072 : * affect blocks already associated with the specified object. After an
1073 : * initially inactive object has been activated, calling
1074 : * dispatch_set_target_queue() results in an assertion and the process being
1075 : * terminated.
1076 : *
1077 : * If a dispatch queue is active and targeted by other dispatch objects,
1078 : * changing its target queue results in undefined behavior.
1079 : *
1080 : * @param object
1081 : * The object to modify.
1082 : * The result of passing NULL in this parameter is undefined.
1083 : *
1084 : * @param queue
1085 : * The new target queue for the object. The queue is retained, and the
1086 : * previous target queue, if any, is released.
1087 : * If queue is DISPATCH_TARGET_QUEUE_DEFAULT, set the object's target queue
1088 : * to the default target queue for the given object type.
1089 : */
1090 : API_AVAILABLE(macos(10.6), ios(4.0))
1091 : DISPATCH_EXPORT DISPATCH_NOTHROW
1092 : void
1093 : dispatch_set_target_queue(dispatch_object_t object,
1094 : dispatch_queue_t _Nullable queue);
1095 :
1096 : /*!
1097 : * @function dispatch_main
1098 : *
1099 : * @abstract
1100 : * Execute blocks submitted to the main queue.
1101 : *
1102 : * @discussion
1103 : * This function "parks" the main thread and waits for blocks to be submitted
1104 : * to the main queue. This function never returns.
1105 : *
1106 : * Applications that call NSApplicationMain() or CFRunLoopRun() on the
1107 : * main thread do not need to call dispatch_main().
1108 : */
1109 : API_AVAILABLE(macos(10.6), ios(4.0))
1110 : DISPATCH_EXPORT DISPATCH_NOTHROW DISPATCH_NORETURN
1111 : void
1112 : dispatch_main(void);
1113 :
1114 : /*!
1115 : * @function dispatch_after
1116 : *
1117 : * @abstract
1118 : * Schedule a block for execution on a given queue at a specified time.
1119 : *
1120 : * @discussion
1121 : * Passing DISPATCH_TIME_NOW as the "when" parameter is supported, but not as
1122 : * optimal as calling dispatch_async() instead. Passing DISPATCH_TIME_FOREVER
1123 : * is undefined.
1124 : *
1125 : * @param when
1126 : * A temporal milestone returned by dispatch_time() or dispatch_walltime().
1127 : *
1128 : * @param queue
1129 : * A queue to which the given block will be submitted at the specified time.
1130 : * The result of passing NULL in this parameter is undefined.
1131 : *
1132 : * @param block
1133 : * The block of code to execute.
1134 : * The result of passing NULL in this parameter is undefined.
1135 : */
1136 : #ifdef __BLOCKS__
1137 : API_AVAILABLE(macos(10.6), ios(4.0))
1138 : DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NONNULL3 DISPATCH_NOTHROW
1139 : void
1140 : dispatch_after(dispatch_time_t when, dispatch_queue_t queue,
1141 : dispatch_block_t block);
1142 : #endif
1143 :
1144 : /*!
1145 : * @function dispatch_after_f
1146 : *
1147 : * @abstract
1148 : * Schedule a function for execution on a given queue at a specified time.
1149 : *
1150 : * @discussion
1151 : * See dispatch_after() for details.
1152 : *
1153 : * @param when
1154 : * A temporal milestone returned by dispatch_time() or dispatch_walltime().
1155 : *
1156 : * @param queue
1157 : * A queue to which the given function will be submitted at the specified time.
1158 : * The result of passing NULL in this parameter is undefined.
1159 : *
1160 : * @param context
1161 : * The application-defined context parameter to pass to the function.
1162 : *
1163 : * @param work
1164 : * The application-defined function to invoke on the target queue. The first
1165 : * parameter passed to this function is the context provided to
1166 : * dispatch_after_f().
1167 : * The result of passing NULL in this parameter is undefined.
1168 : */
1169 : API_AVAILABLE(macos(10.6), ios(4.0))
1170 : DISPATCH_EXPORT DISPATCH_NONNULL2 DISPATCH_NONNULL4 DISPATCH_NOTHROW
1171 : void
1172 : dispatch_after_f(dispatch_time_t when, dispatch_queue_t queue,
1173 : void *_Nullable context, dispatch_function_t work);
1174 :
1175 : /*!
1176 : * @functiongroup Dispatch Barrier API
1177 : * The dispatch barrier API is a mechanism for submitting barrier blocks to a
1178 : * dispatch queue, analogous to the dispatch_async()/dispatch_sync() API.
1179 : * It enables the implementation of efficient reader/writer schemes.
1180 : * Barrier blocks only behave specially when submitted to queues created with
1181 : * the DISPATCH_QUEUE_CONCURRENT attribute; on such a queue, a barrier block
1182 : * will not run until all blocks submitted to the queue earlier have completed,
1183 : * and any blocks submitted to the queue after a barrier block will not run
1184 : * until the barrier block has completed.
1185 : * When submitted to a a global queue or to a queue not created with the
1186 : * DISPATCH_QUEUE_CONCURRENT attribute, barrier blocks behave identically to
1187 : * blocks submitted with the dispatch_async()/dispatch_sync() API.
1188 : */
1189 :
1190 : /*!
1191 : * @function dispatch_barrier_async
1192 : *
1193 : * @abstract
1194 : * Submits a barrier block for asynchronous execution on a dispatch queue.
1195 : *
1196 : * @discussion
1197 : * Submits a block to a dispatch queue like dispatch_async(), but marks that
1198 : * block as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT queues).
1199 : *
1200 : * See dispatch_async() for details.
1201 : *
1202 : * @param queue
1203 : * The target dispatch queue to which the block is submitted.
1204 : * The system will hold a reference on the target queue until the block
1205 : * has finished.
1206 : * The result of passing NULL in this parameter is undefined.
1207 : *
1208 : * @param block
1209 : * The block to submit to the target dispatch queue. This function performs
1210 : * Block_copy() and Block_release() on behalf of callers.
1211 : * The result of passing NULL in this parameter is undefined.
1212 : */
1213 : #ifdef __BLOCKS__
1214 : API_AVAILABLE(macos(10.7), ios(4.3))
1215 : DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
1216 : void
1217 : dispatch_barrier_async(dispatch_queue_t queue, dispatch_block_t block);
1218 : #endif
1219 :
1220 : /*!
1221 : * @function dispatch_barrier_async_f
1222 : *
1223 : * @abstract
1224 : * Submits a barrier function for asynchronous execution on a dispatch queue.
1225 : *
1226 : * @discussion
1227 : * Submits a function to a dispatch queue like dispatch_async_f(), but marks
1228 : * that function as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT
1229 : * queues).
1230 : *
1231 : * See dispatch_async_f() for details.
1232 : *
1233 : * @param queue
1234 : * The target dispatch queue to which the function is submitted.
1235 : * The system will hold a reference on the target queue until the function
1236 : * has returned.
1237 : * The result of passing NULL in this parameter is undefined.
1238 : *
1239 : * @param context
1240 : * The application-defined context parameter to pass to the function.
1241 : *
1242 : * @param work
1243 : * The application-defined function to invoke on the target queue. The first
1244 : * parameter passed to this function is the context provided to
1245 : * dispatch_barrier_async_f().
1246 : * The result of passing NULL in this parameter is undefined.
1247 : */
1248 : API_AVAILABLE(macos(10.7), ios(4.3))
1249 : DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW
1250 : void
1251 : dispatch_barrier_async_f(dispatch_queue_t queue,
1252 : void *_Nullable context, dispatch_function_t work);
1253 :
1254 : /*!
1255 : * @function dispatch_barrier_sync
1256 : *
1257 : * @abstract
1258 : * Submits a barrier block for synchronous execution on a dispatch queue.
1259 : *
1260 : * @discussion
1261 : * Submits a block to a dispatch queue like dispatch_sync(), but marks that
1262 : * block as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT queues).
1263 : *
1264 : * See dispatch_sync() for details.
1265 : *
1266 : * @param queue
1267 : * The target dispatch queue to which the block is submitted.
1268 : * The result of passing NULL in this parameter is undefined.
1269 : *
1270 : * @param block
1271 : * The block to be invoked on the target dispatch queue.
1272 : * The result of passing NULL in this parameter is undefined.
1273 : */
1274 : #ifdef __BLOCKS__
1275 : API_AVAILABLE(macos(10.7), ios(4.3))
1276 : DISPATCH_EXPORT DISPATCH_NONNULL_ALL DISPATCH_NOTHROW
1277 : void
1278 : dispatch_barrier_sync(dispatch_queue_t queue,
1279 : DISPATCH_NOESCAPE dispatch_block_t block);
1280 : #endif
1281 :
1282 : /*!
1283 : * @function dispatch_barrier_sync_f
1284 : *
1285 : * @abstract
1286 : * Submits a barrier function for synchronous execution on a dispatch queue.
1287 : *
1288 : * @discussion
1289 : * Submits a function to a dispatch queue like dispatch_sync_f(), but marks that
1290 : * fuction as a barrier (relevant only on DISPATCH_QUEUE_CONCURRENT queues).
1291 : *
1292 : * See dispatch_sync_f() for details.
1293 : *
1294 : * @param queue
1295 : * The target dispatch queue to which the function is submitted.
1296 : * The result of passing NULL in this parameter is undefined.
1297 : *
1298 : * @param context
1299 : * The application-defined context parameter to pass to the function.
1300 : *
1301 : * @param work
1302 : * The application-defined function to invoke on the target queue. The first
1303 : * parameter passed to this function is the context provided to
1304 : * dispatch_barrier_sync_f().
1305 : * The result of passing NULL in this parameter is undefined.
1306 : */
1307 : API_AVAILABLE(macos(10.7), ios(4.3))
1308 : DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NONNULL3 DISPATCH_NOTHROW
1309 : void
1310 : dispatch_barrier_sync_f(dispatch_queue_t queue,
1311 : void *_Nullable context, dispatch_function_t work);
1312 :
1313 : /*!
1314 : * @functiongroup Dispatch queue-specific contexts
1315 : * This API allows different subsystems to associate context to a shared queue
1316 : * without risk of collision and to retrieve that context from blocks executing
1317 : * on that queue or any of its child queues in the target queue hierarchy.
1318 : */
1319 :
1320 : /*!
1321 : * @function dispatch_queue_set_specific
1322 : *
1323 : * @abstract
1324 : * Associates a subsystem-specific context with a dispatch queue, for a key
1325 : * unique to the subsystem.
1326 : *
1327 : * @discussion
1328 : * The specified destructor will be invoked with the context on the default
1329 : * priority global concurrent queue when a new context is set for the same key,
1330 : * or after all references to the queue have been released.
1331 : *
1332 : * @param queue
1333 : * The dispatch queue to modify.
1334 : * The result of passing NULL in this parameter is undefined.
1335 : *
1336 : * @param key
1337 : * The key to set the context for, typically a pointer to a static variable
1338 : * specific to the subsystem. Keys are only compared as pointers and never
1339 : * dereferenced. Passing a string constant directly is not recommended.
1340 : * The NULL key is reserved and attempts to set a context for it are ignored.
1341 : *
1342 : * @param context
1343 : * The new subsystem-specific context for the object. This may be NULL.
1344 : *
1345 : * @param destructor
1346 : * The destructor function pointer. This may be NULL and is ignored if context
1347 : * is NULL.
1348 : */
1349 : API_AVAILABLE(macos(10.7), ios(5.0))
1350 : DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_NOTHROW
1351 : void
1352 : dispatch_queue_set_specific(dispatch_queue_t queue, const void *key,
1353 : void *_Nullable context, dispatch_function_t _Nullable destructor);
1354 :
1355 : /*!
1356 : * @function dispatch_queue_get_specific
1357 : *
1358 : * @abstract
1359 : * Returns the subsystem-specific context associated with a dispatch queue, for
1360 : * a key unique to the subsystem.
1361 : *
1362 : * @discussion
1363 : * Returns the context for the specified key if it has been set on the specified
1364 : * queue.
1365 : *
1366 : * @param queue
1367 : * The dispatch queue to query.
1368 : * The result of passing NULL in this parameter is undefined.
1369 : *
1370 : * @param key
1371 : * The key to get the context for, typically a pointer to a static variable
1372 : * specific to the subsystem. Keys are only compared as pointers and never
1373 : * dereferenced. Passing a string constant directly is not recommended.
1374 : *
1375 : * @result
1376 : * The context for the specified key or NULL if no context was found.
1377 : */
1378 : API_AVAILABLE(macos(10.7), ios(5.0))
1379 : DISPATCH_EXPORT DISPATCH_NONNULL1 DISPATCH_PURE DISPATCH_WARN_RESULT
1380 : DISPATCH_NOTHROW
1381 : void *_Nullable
1382 : dispatch_queue_get_specific(dispatch_queue_t queue, const void *key);
1383 :
1384 : /*!
1385 : * @function dispatch_get_specific
1386 : *
1387 : * @abstract
1388 : * Returns the current subsystem-specific context for a key unique to the
1389 : * subsystem.
1390 : *
1391 : * @discussion
1392 : * When called from a block executing on a queue, returns the context for the
1393 : * specified key if it has been set on the queue, otherwise returns the result
1394 : * of dispatch_get_specific() executed on the queue's target queue or NULL
1395 : * if the current queue is a global concurrent queue.
1396 : *
1397 : * @param key
1398 : * The key to get the context for, typically a pointer to a static variable
1399 : * specific to the subsystem. Keys are only compared as pointers and never
1400 : * dereferenced. Passing a string constant directly is not recommended.
1401 : *
1402 : * @result
1403 : * The context for the specified key or NULL if no context was found.
1404 : */
1405 : API_AVAILABLE(macos(10.7), ios(5.0))
1406 : DISPATCH_EXPORT DISPATCH_PURE DISPATCH_WARN_RESULT DISPATCH_NOTHROW
1407 : void *_Nullable
1408 : dispatch_get_specific(const void *key);
1409 :
1410 : /*!
1411 : * @functiongroup Dispatch assertion API
1412 : *
1413 : * This API asserts at runtime that code is executing in (or out of) the context
1414 : * of a given queue. It can be used to check that a block accessing a resource
1415 : * does so from the proper queue protecting the resource. It also can be used
1416 : * to verify that a block that could cause a deadlock if run on a given queue
1417 : * never executes on that queue.
1418 : */
1419 :
1420 : /*!
1421 : * @function dispatch_assert_queue
1422 : *
1423 : * @abstract
1424 : * Verifies that the current block is executing on a given dispatch queue.
1425 : *
1426 : * @discussion
1427 : * Some code expects to be run on a specific dispatch queue. This function
1428 : * verifies that that expectation is true.
1429 : *
1430 : * If the currently executing block was submitted to the specified queue or to
1431 : * any queue targeting it (see dispatch_set_target_queue()), this function
1432 : * returns.
1433 : *
1434 : * If the currently executing block was submitted with a synchronous API
1435 : * (dispatch_sync(), dispatch_barrier_sync(), ...), the context of the
1436 : * submitting block is also evaluated (recursively).
1437 : * If a synchronously submitting block is found that was itself submitted to
1438 : * the specified queue or to any queue targeting it, this function returns.
1439 : *
1440 : * Otherwise this function asserts: it logs an explanation to the system log and
1441 : * terminates the application.
1442 : *
1443 : * Passing the result of dispatch_get_main_queue() to this function verifies
1444 : * that the current block was submitted to the main queue, or to a queue
1445 : * targeting it, or is running on the main thread (in any context).
1446 : *
1447 : * When dispatch_assert_queue() is called outside of the context of a
1448 : * submitted block (for example from the context of a thread created manually
1449 : * with pthread_create()) then this function will also assert and terminate
1450 : * the application.
1451 : *
1452 : * The variant dispatch_assert_queue_debug() is compiled out when the
1453 : * preprocessor macro NDEBUG is defined. (See also assert(3)).
1454 : *
1455 : * @param queue
1456 : * The dispatch queue that the current block is expected to run on.
1457 : * The result of passing NULL in this parameter is undefined.
1458 : */
1459 : API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
1460 : DISPATCH_EXPORT DISPATCH_NONNULL1
1461 : void
1462 : dispatch_assert_queue(dispatch_queue_t queue)
1463 : DISPATCH_ALIAS_V2(dispatch_assert_queue);
1464 :
1465 : /*!
1466 : * @function dispatch_assert_queue_barrier
1467 : *
1468 : * @abstract
1469 : * Verifies that the current block is executing on a given dispatch queue,
1470 : * and that the block acts as a barrier on that queue.
1471 : *
1472 : * @discussion
1473 : * This behaves exactly like dispatch_assert_queue(), with the additional check
1474 : * that the current block acts as a barrier on the specified queue, which is
1475 : * always true if the specified queue is serial (see DISPATCH_BLOCK_BARRIER or
1476 : * dispatch_barrier_async() for details).
1477 : *
1478 : * The variant dispatch_assert_queue_barrier_debug() is compiled out when the
1479 : * preprocessor macro NDEBUG is defined. (See also assert()).
1480 : *
1481 : * @param queue
1482 : * The dispatch queue that the current block is expected to run as a barrier on.
1483 : * The result of passing NULL in this parameter is undefined.
1484 : */
1485 : API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
1486 : DISPATCH_EXPORT DISPATCH_NONNULL1
1487 : void
1488 : dispatch_assert_queue_barrier(dispatch_queue_t queue);
1489 :
1490 : /*!
1491 : * @function dispatch_assert_queue_not
1492 : *
1493 : * @abstract
1494 : * Verifies that the current block is not executing on a given dispatch queue.
1495 : *
1496 : * @discussion
1497 : * This function is the equivalent of dispatch_queue_assert() with the test for
1498 : * equality inverted. That means that it will terminate the application when
1499 : * dispatch_queue_assert() would return, and vice-versa. See discussion there.
1500 : *
1501 : * The variant dispatch_assert_queue_not_debug() is compiled out when the
1502 : * preprocessor macro NDEBUG is defined. (See also assert(3)).
1503 : *
1504 : * @param queue
1505 : * The dispatch queue that the current block is expected not to run on.
1506 : * The result of passing NULL in this parameter is undefined.
1507 : */
1508 : API_AVAILABLE(macos(10.12), ios(10.0), tvos(10.0), watchos(3.0))
1509 : DISPATCH_EXPORT DISPATCH_NONNULL1
1510 : void
1511 : dispatch_assert_queue_not(dispatch_queue_t queue)
1512 : DISPATCH_ALIAS_V2(dispatch_assert_queue_not);
1513 :
1514 : #ifdef NDEBUG
1515 : #define dispatch_assert_queue_debug(q) ((void)(0 && (q)))
1516 : #define dispatch_assert_queue_barrier_debug(q) ((void)(0 && (q)))
1517 : #define dispatch_assert_queue_not_debug(q) ((void)(0 && (q)))
1518 : #else
1519 : #define dispatch_assert_queue_debug(q) dispatch_assert_queue(q)
1520 : #define dispatch_assert_queue_barrier_debug(q) dispatch_assert_queue_barrier(q)
1521 : #define dispatch_assert_queue_not_debug(q) dispatch_assert_queue_not(q)
1522 : #endif
1523 :
1524 : __END_DECLS
1525 :
1526 : DISPATCH_ASSUME_NONNULL_END
1527 :
1528 : #endif
|


Figures & Code Examples
- Weird animation names work
- Keywords as animation names are a bad idea
- The W animation
- No 0% or 100% keyframes
- Without a midpoint, auto doesn’t animate well
- Setting/omitting initial values and 0%
- Animation API
- Unfortunate animation names
- Keywords as animation names are a bad idea (redux)
- No 0% or 100% keyframes (redux)
- Visualizing background color changes over time
- animation-duration with invalid value
- Using fractional duration values
- Basic bouncing ball
- Partial animation
- Bouncing ball animation with negative animation delay
- Animation events
- Animation events, again
- Animation chaining
- Animation following and animation
- Animation chaining with Javascript
- Animation iteration delay with Javascript
- Animation iteration delay
- Animation iteration delay
- Animation iteration delay
- Animation iteration delay
- Animation iteration delay (redux)
- Cubic Bézier named functions
- An outlandish Bézier curve
- Effect of outlandish Bézier curve
- Representation of a cubic Bézier curve
- Better bouncing ball animation
- Sprite of dancing
- Steps timing function, Gangam style
- Visualizing start and end change points
- Steps timing function with translate transforms
- Changing the animation timing function mid-animation
- Representation of another cubic Bézier curve
- Bodacious bouncing ball animation
- Interactive bouncing ball animation
- Partial iteration with fill-mode
- Partial iteration with fill-mode, again
- A snowflake
- Running animations take precedence
- Last declared anaimation takes precedence
- A snowflake with animation starts and stops


Output:
Output:
Calculating...
Output:
Calculating...
Chatbot demo!
It only knows how to answer to
- hi
- hello
- how are you
- tell me something interesting


SBV believes cryptocurrencies are ‘illegal payment tools’ in the country, and the issue, supply and use of Bitcoin and other virtual currencies should be prohibited.
With a quite inspiring development momentum,KyberNetwork has made accomplishments recently not only in its project progress, but also in collaborations with multiple platforms
Featuring an Ethereum-based network and wallet, they want to offer customers an easy and quick way to handle money without having to rely on a bank as 3rd party.
Besides serving as an exchange, Kyber Network also provides payment APIs that will allow wallet accounts to easily receive payments from any crypto tokens.
Red Belly Blockchain can process 660,000 transactions/sec in the latest tests, much quicker than the Visa network and 50 percent faster than first anticipated.
Bitcoin is a cryptocurrency, people should focus more on its value and daily applications rather than the unstable price.
The Blockchain is penetrating into various currently. Isn’t it amazing to have our diploma recorded on Blockchain for permanent storage? Of course it is, and it is impossible to happen years ago.
The end of Bitcoin GST will definitely be a good sign to cryptocurrency world.
Blcokchain and cryptocurrency are entering the mainstream of today’s economic reality and supported by quite positive development environment
Government licensing is quite important when establishing a payments business. Official approval in a leading European financial center like Switzerland is a key plus in the competitive environment.
EEA is a nonprofit alliance with the objective of creating a series of standards for Ethereum in terms of security, privacy, scalability and interoperability.
Blockchain technology is believed to be the best way to help refugees to recreate their lost identities
DAH has raised $40 million in Series B round, bringing the its current total funding to $110 million
China’s current bitcoin transaction in global market share has plunged to 2%, while people in bitcoin circle are wondering whether ‘mining’ will also be restricted or prohibited or not.
Fiat digital currency is far more than the digitization of currency; most importantly, it makes the currency smarter.
Alibaba today is more than a commercial company. The public empowered us, it’s time to be giving back, we must do something to live up to people’s expectations. We should develop the vision that to take responsibility for the world. –Jack Ma, Jack Ma, the founder of Alibaba
After the China’s ban on ICO related activities, many ICO and virtual currency trading platforms stop their business and some are arranging refunding affairs in according with the law, the upcoming ICO projects also stops here.
As the morning sun rises, glowing rays shine. Not dazzling though, the first light of the morning heralds limitless possibilities.
Tax payment in Bitcoin in Swiss Chiasso will put into place at the beginning of the next year
Blockchain bank transfers test is just a beginning, what will happen in the upcoming future? Will this completely replace the existing bank transfer system? Let’s see!
The Blockchain Embassy functions not only as a place for technology fans, but also for developers to share and communicate views and researches on this space. You can also enjoy talking over a cup of coffee or beer as it provides cafeteria service
Many countries are working on the legislation for the use of cryptocurrency. They are a kind of unstable digital asset, thus certain regulatory is necessary to avoid the potential risks that may be faced by investors.
The EU explores Blockchain technology, investing big amount of money to help startups in this space.
ERC-20 standard guarantees a common rule when issuing Ethereum-based tokens, which means in the future, all Ethereum-based tokens should perform under this standard.
HongKong SFC suggests that some tokens issued by ICO projects may belong to securities
Regulatory authorities said ICO is an unauthorized illegal fund-raising that may involve in illegal sale of tokens, financial fraud, pyramid schemes and other criminal activities.
Technology giant IBM has partnered with giants in global food supply chain to launch a blockchain consortium focusing on food safety.
Ethereum developers build enterprise-level open-source technology implementations in a new way.
Are smart contracts legally binding? If the Enterprise Ethereum Alliance’s new members have anything to say about it, that might someday change.
Securing and sharing student records, Blockchain begins to be used in Education .
A Russian airline has announced that it will use the ethereum blockchain to sell flight tickets backed by the country’s largest private commercial bank.
The block chain is gradually penetrating into the logistics industry. Block chain and logistics seem to be a perfect combination. This year, we witness the market’s growing interest in block chain’s influence in logistics and transportation.
A trade finance transaction through blockchain ended between Mizuho Bank, a Japanese banking giant and Australia. The detailed information of this trade was also released.
Australia’s University of Sydney (USYD) researchers are currently developing a new block chain model which reportedly can handle 440 thousand transactions every second. The participants believe this new system has a potential to revolutionize the global economy.
As part of a pilot trial, Daimler AG, the German automaker and the parent company of Mercedes-Benz has issued a corporate bond worth 100 million Euros.
Recently, Barclays CEO, Ashok Vaswani revealed that the bank has been communicating with Britain’s Financial Conduct Authority (FCA) and actively talking with UK regulators about how to bring bitcoin “into play” within the UK fintech industry. According to Ashok Vaswani, Barclays has met with FCA, Britain’s chief regulatory watchdog overseeing the fintech industry, to talk about the regulation of virtual currency with the aim to work out ways to safely regulate bitcoin.
The Australian Securities Exchange (hereinafter referred to as ASX) announced on Wednesday that bitcoin can be used to buy the stake in a company listed on its exchange. Blockchain Global Limited (BGL) has committed to buy a 40 percent interest in Digitalx, paying partly in bitcoins.
Recently, the executive director of Taurus Wealth Advisors, Rainer Michael Preiss said that bitcoin can save the global economy.
In the future, the Blockchain will lead the internet of information towards the internet of value to build a brand new trustworthy society


Before we chose our project we went to Buveco, a gas detection company, to discuss the inefficiencies with Carbon
Monoxide detectors in steel factories. The thing is, all Carbon Monoxide detectors have hydrogen interference. They
detect hydrogen and carbon monoxide as the same. If the carbon monoxide detector goes off, there is no telling if
the carbon monoxide levels are actually dangerous or that there is just a lot of hydrogen interference.
Buveco showed us their workplace and how their Carbon Monoxide detector works. With this information of
Buveco about hydrogen interference we started to think of a way to make the detector specific for only Carbon
Monoxide. We looked for a protein which only binds Carbon Monoxide and found CooA in combination with CooF and CooM
promotors.
They thought we had a very good idea and they did sponsor us with materials. We received the carbon monoxide
detector they sell to factories, CO and hydrogen tanks. This so we can test our own detector.
Since we’re working with the dangerous gas carbonmonoxide, we got a safety course from one of our main
sponsors, Buveco, on how to handle the gas and the tank. Also did we get a working sensor, which can alarm us in
case the gas leaks. Furthermore did we get a concentration of CO in the tank, which is not harmful when leaking for
8 hours. Buveco is our most important contact about CO detectors. We learnt a lot from them.
| Q: | Carbonmonoxide detectors without an interference with hydrogen don't exist yet, do you know why hydrogen interferes and why there is no solution yet? |
| A: | The interferention has to do with the electrochemical sensor on the detector. According to sensor manufacturers it is very difficult to develop a carbonmonoxide detector without the interference. There are detectors that are optimalised and suffer less from interference, but it is often at the expanse of the response time. |
| Q: | What do you think of our plan of developing a selective carbonmonoxide detector? And what is your opinion about introducing GMO's in the design? |
| A: | The idea of designing a selective carbon monoxide detector is great. However, we don't have enough knowledge to decide if the GMO's in the detector could work as an alternative. |
| Q: | Do you think the GMO's could be a reason for consumers to not buy the detector, even if it's declared safe? |
| A: | We don't dare to make a substantiated statement about this question. |
| Q: | Would you be interested in buying our gadget and/or optimalising it? |
| A: | On short term no, the main reason for this is the lack of resources. Besides that, we don't produce the sensors ourselves but produce the complete detector. The sensors are bought parts and produced by another company. |
| Q: | Do you have any tips for our team on optimalising and improving the selective carbon monoxide detector? |
| A: | Also test on other aspects, like overload, lifetime, reactiontime, temperature sensitivity, sensitivity to humidity, pressure differences, influences of other gasses and of course the cost price aspect. |
| Q: | Why did you decide to sponsor us? Do you see a future in the project, or do you like to help students who work on different issues like the carbon monoxide detector? |
| A: | Every now and then we serve a social purpose. This is not a core task, and we don't sponsor all the social purposes. This came on our path and appealed to us. |
| Q: | What do you think that our chances are at a successful project, with a potential market for our device? |
| A: | That depends on the specifications. For example, the selectivity of the sensor, the resistance of external influences, overload and of course the selectivity on other gasses. By which we mean are there any other standard gasses in such work environments that can adversely affect the sensor. |
Our team member Randall went to the dutch RIVM meeting on the 14th of May. He was a bit overeager (and early) since
he was the first student to arrive.
The RIVM meeting is an information day mostly about safety. It was an interesting meeting for the dutch iGEM
teams.
After this we had 2 skype calls with members of the RIVM (June 20th and August 17th). We discussed how we
were planning to make our product, and they gave us advice where to think of.
 But the advice was: you can build a kill switch
(which is more difficult to make and you never really know if i works in every bacteria), but you can better build
your device so, it can never break. This we will take with us when we are going to build the device.
We know there are strict rules for bringing genetically modified organisms (GMO’s) outside the laboratory.
So they advised us to think of a way to replace the GMO’s in a later stadium of our product, which we maybe have to
do if the GMO rules stay the same.


Project 1
About project 1.
Project 2
About project 2.
Project 3
About project 3.
Project 4
About project 4.
Project 5
About project 5.
Project 6
About project 6.
About project 1.
About project 2.
About project 3.
About project 4.
About project 5.
About project 6.


Prefix for URLs for authentication with GitHub.
Stores the expiry date of the cookie set.
Exported as cookieExpiry
.
Stores the domain name for callback url after successful authentication.
Exported as hostUrl
for callback after GitHub sends code
.
Stores the type of environment of project. It is either development
or
production
.
Exported as nodeEnv
to differentiate behaviour of app on development and
production server.
Stores the pagination size of displaying gists.
Exported as paginationSize
.
Secret used to sign the session ID cookie.
Exported as sessionSecret
to configure cookie creation.
Stores the different types of URLs required for authentication.
Exported as authUrl
for configuring endpoints of authentication.
The URL redirected to after successful authentication with GitHub.
Endpoint to verify if the user is authenticated.
Endpoint for signing out of the back-end service.
Endpoint for signing in with GitHub.
Stores the client ID and client secret of GitHub OAuth application created here.
Exported as githubOauth
for configuring GitHub passport strategy.
Client ID of OAuth application.
Client secret of OAuth application.
Stores redirection URL for successful and failed authentication.
Exported as redirectUrl
for redirections.
The URL redirected to if the user is not logged in.
The URL redirected by this back-end service to homepage.
Stores the configuration for redis store.
Host name for redis store.
Host password for redis store.
Port number for redis store.
Generated using TypeDoc
OAuth strategy to authenticate with GitHub. Reference: http://www.passportjs.org/packages/passport-github2/


| Class | Parent | Description |
|---|---|---|
{{ item.class }} |
{{ item.applies }} |
{{ item.description }} |
Post summaries are a flexible component capable of previewing various content types—questions or articles. Post summaries are meant to be flexible, allowing for each individual piece to be removed. Let’s start with a full example of a few questions and an article interleaved.
{% header "h3", "Full" %}At their most complete, post summaries are presented in two columns and can contain:
At the smallest breakpoint, the layout will switch to a single column.
In the spirit of type safety associated with the CriteriaQuery JPA 2.0 also has an API to support Metamodel representation of entities.
{% icon "EllipsisVertical" %} menuI am creating my first react-native app. I am attempting to install the react-native command line interface as shown here. I keep getting an error when I type the command to initiate the react-native command line
{% icon "EllipsisVertical" %} menuThis article aims to guide you through the steps and processes you may want to consider when running research at Stack Overflow. While there are obviously many methods, this guide will focus more interview-style research. For a full list of Product Research templates, guides, and links, see this article.
{% icon "EllipsisVertical" %} menuI’m trying to implement DDD approach in my project but realized that I have too big aggregates and trying to minimize the amount of data loaded from the database. I have an aggregate Order which
{% icon "EllipsisVertical" %} menuThere are compact views where it’s appropriate to reduce the amount of information within the post summary. The minimal view forces the smallest breakpoint layout in any context, stacking the meta data on top and putting everything into a single column.
Posts can be shown with or without excerpts. Stacks also provides various size
…
…
…
…
{% endhighlight %}In the spirit of type safety associated with the CriteriaQuery JPA 2.0 also has an API to support Metamodel representation of entities. Is anyone aware of a fully functional implementation of this API (to generate the Metamodel as opposed to creating the metamodel classes manually)? It would be awesome if someone also knows the steps for setting this up in Eclipse (I assume it's as simple as setting up an annotation processor, but you never know).
{% icon "EllipsisVertical" %} menuIn the spirit of type safety associated with the CriteriaQuery JPA 2.0 also has an API to support Metamodel representation of entities. Is anyone aware of a fully functional implementation of this API (to generate the Metamodel as opposed to creating the metamodel classes manually)? It would be awesome if someone also knows the steps for setting this up in Eclipse (I assume it's as simple as setting up an annotation processor, but you never know).
{% icon "EllipsisVertical" %} menuIn the spirit of type safety associated with the CriteriaQuery JPA 2.0 also has an API to support Metamodel representation of entities. Is anyone aware of a fully functional implementation of this API (to generate the Metamodel as opposed to creating the metamodel classes manually)? It would be awesome if someone also knows the steps for setting this up in Eclipse (I assume it's as simple as setting up an annotation processor, but you never know).
{% icon "EllipsisVertical" %} menuIn the spirit of type safety associated with the CriteriaQuery JPA 2.0 also has an API to support Metamodel representation of entities. Is anyone aware of a fully functional implementation of this API (to generate the Metamodel as opposed to creating the metamodel classes manually)? It would be awesome if someone also knows the steps for setting this up in Eclipse (I assume it's as simple as setting up an annotation processor, but you never know).
{% icon "EllipsisVertical" %} menuPreviews of answers can also be attached to the post summary as needed.
…
Right now, I have enabled basic authentication to the developer portal in API Management. Also, I have enabled OAuth 2.0 authentication for the back end server (user Authorization). So, if i login to the developer portal, i can see two fields - Subscription Key and Authorization. The Subscription key will be the developer's subscription to the portal and the Authorization will be the OAuth authorization which is required for the back end server.
Subscription keys in APIM are tied to a user and product, thus if you change (or create new one) product to not require subscription (option available at creation time or in product settings) no subscription key would be needed to call any API included into such products. The downside is that all such calls would be treated by APIM as anonymous and shown in analytics as such.
Yeah, you can do that (a bit of a hack). You have to use REST Api for that, specifically this call. For me it didn't work to edit the existing API (they key was still there), but when I've created new API, key wasn't there:
Within the stats section of the post summary, posts can have various answered states. A checkmark icon is displayed in questions that have accepted answers.
Post stats also have various states of hotness and display in corresponding shades of orange.
Post summaries change their appearance based on being watched, ignored, or deleted. Articles can also have varying draft states.
I wanted to see how different tags related to each other. The below graph depicts associations between popular tags on our site. Description of analysis: I started looking at the 1000 most popular tags on questions in 2021. I created a list of tags cross joined by the question ID (so if a question contains tags for both Python and Numpy, it would show up in my list). I scaled up by the number of answers each question received (noting that some tag combos had 0 answers) -and then counted each distinct combination of each tag. Due to limitations in graphing, I only displayed the top ~2500 tag combinations - which accounts for tags combos that had more than 40 answers over the entire year.
{% icon "EllipsisVertical" %} menuSometimes after build and launch my MVC4 web app I got this error. It can dissapear after rebuild or not. Same issue I got after publish to Windows Azure. Does anybody know how to fix this error?
{% icon "EllipsisVertical" %} menuI recently found this solution for doing php url variable to header location redirects. It's so much more manageable compared to htaccess for mass redirects, however one thing I want to next work out templates, guides, and links, see this article.
{% icon "EllipsisVertical" %} menuI am working on a Spring Boot application with user authentication is based on Oauth2 2ith 2FA. Now, I would like to call the APIs in my application from the third-party client as well, say from another service.
{% icon "EllipsisVertical" %} menuCloud SQL allows users to customize several flags that allow you to adjust options and configure and tune a database instance. In the case of the sql_mode flag, there are several options that are
{% icon "EllipsisVertical" %} menuIn Android apps that use Firebase Authentication, you can always get the user who is currently signed in with code like: FirebaseAuth auth = FirebaseAuth.getInstance(); FirebaseUser user = auth.get
{% icon "EllipsisVertical" %} menuIn Android apps that use Firebase Authentication, you can always get the user who is currently signed in with code like: FirebaseAuth auth = FirebaseAuth.getInstance(); FirebaseUser user = auth.get
{% icon "EllipsisVertical" %} menuWe’re pleased to announce gcloud storage, a new set of Cloud Storage commands in Cloud SDK that includes a new approach to parallelization that can accelerate both small and large data migrations.
{% icon "EllipsisVertical" %} menu


Integration with Drupal Services X-CSRF-Token header.
This code relies on this tag to be added to the page BEFORE the main application script tag.
<script src="services/session/token.json"></script>


Some Internet pages might get automatically translated according to your computer's settings. Although this might be useful in everyday life, in this project we ask you to output the data in English. To force requests
library to return a page in English, you can use headers
with Accept-Language
parameter set to the value en-US,en;q=0.5
:
response = requests.get(url, headers={'Accept-Language': 'en-US,en;q=0.5'})
Note that the structure of the page might be different in cases when you use this header and when you don't (even if your default language is English).
We know how to send HTTP requests and get responses. In the previous stage, the example URL responded with the json
body, this is how the REST
resources communicate with a client. We, humans, go to websites to access the Internet. We also have browsers, but sometimes we need to parse the website's content automatically. Parsing is one of the ways to scrape a webpage.
Parsing website data begins with the inspection of the page source code with browser built-in tools. Usually, the desired information can be distinguished by some unique attributes or a set of attributes, for example, a css class
name. We need to determine these attributes and then make our parsing tool (in our case, the beautifulsoup library) do the magic for us.
https://www.imdb.com/title/tt0080684/
. Note that the link to a movie or a TV series always contains the word 'title' in it.<title>
tag. The description can be found in the <meta>
tag with the following template: soup.find('meta', {'name':'description'})
. You can access the text within the tags via the text
and the ['content']
attributes, respectively.If the received page doesn't have a movie description or is not an IMDb resource, the program should respond with the Invalid movie page!
message, just like in the previous stage.
A user inputs a URL with a movie description to store it in the response dictionary. If the link is not correct or does not contain a movie original title and description, the program responds with an error message.
The greater-than symbol followed by a space (>
) represents the user input. Note that it's not part of the input. Each example corresponds to a separate execution.
Example 1
Input the URL:
> https://www.imdb.com/title/tt0080684/
{"title": "Star Wars: Episode V - The Empire Strikes Back", "description": "After the Rebels are brutally overpowered by the Empire on the ice planet Hoth, Luke Skywalker begins Jedi training with Yoda, while his friends are pursued by Darth Vader and a bounty hunter named Boba Fett all over the galaxy."}
Example 2
Input the URL:
> https://www.imdb.com/name/nm0001191/
Invalid movie page!
Example 3
Input the URL:
> https://www.google.com/
Invalid movie page!


¶ SpamPrevention MiddlewareUsage: spamPrevention After: Before: App: Admin|Blog|API Helpers to handle spam detection on signin, forgot password, and protected pages. |
var _ = require('lodash'),
errors = require('../errors'),
config = require('../config'),
loginSecurity = [],
forgottenSecurity = [],
protectedSecurity = [],
spamPrevention;
spamPrevention = {
/*jslint unparam:true*/
|
|
limit signin requests to ten failed requests per IP per hour |
signin: function signin(req, res, next) {
var currentTime = process.hrtime()[0],
remoteAddress = req.connection.remoteAddress,
deniedRateLimit = '',
ipCount = '',
message = 'Too many attempts.',
rateSigninPeriod = config.rateSigninPeriod || 3600,
rateSigninAttempts = config.rateSigninAttempts || 10;
if (req.body.username && req.body.grant_type === 'password') {
loginSecurity.push({ip: remoteAddress, time: currentTime, email: req.body.username});
} else if (req.body.grant_type === 'refresh_token') {
return next();
} else {
return next(new errors.BadRequestError('No username.'));
}
|
|
filter entries that are older than rateSigninPeriod |
loginSecurity = _.filter(loginSecurity, function filter(logTime) {
return (logTime.time + rateSigninPeriod > currentTime);
});
|
|
check number of tries per IP address |
ipCount = _.chain(loginSecurity).countBy('ip').value();
deniedRateLimit = (ipCount[remoteAddress] > rateSigninAttempts);
if (deniedRateLimit) {
errors.logError(
'Only ' + rateSigninAttempts + ' tries per IP address every ' + rateSigninPeriod + ' seconds.',
'Too many login attempts.'
);
message += rateSigninPeriod === 3600 ? ' Please wait 1 hour.' : ' Please try again later';
return next(new errors.TooManyRequestsError(message));
}
next();
},
|
|
limit forgotten password requests to five requests per IP per hour for different email addresses limit forgotten password requests to five requests per email address |
forgotten: function forgotten(req, res, next) {
var currentTime = process.hrtime()[0],
remoteAddress = req.connection.remoteAddress,
rateForgottenPeriod = config.rateForgottenPeriod || 3600,
rateForgottenAttempts = config.rateForgottenAttempts || 5,
email = req.body.passwordreset[0].email,
ipCount = '',
deniedRateLimit = '',
deniedEmailRateLimit = '',
message = 'Too many attempts.',
index = _.findIndex(forgottenSecurity, function findIndex(logTime) {
return (logTime.ip === remoteAddress && logTime.email === email);
});
if (email) {
if (index !== -1) {
forgottenSecurity[index].count = forgottenSecurity[index].count + 1;
} else {
forgottenSecurity.push({ip: remoteAddress, time: currentTime, email: email, count: 0});
}
} else {
return next(new errors.BadRequestError('No email.'));
}
|
|
filter entries that are older than rateForgottenPeriod |
forgottenSecurity = _.filter(forgottenSecurity, function filter(logTime) {
return (logTime.time + rateForgottenPeriod > currentTime);
});
|
|
check number of tries with different email addresses per IP |
ipCount = _.chain(forgottenSecurity).countBy('ip').value();
deniedRateLimit = (ipCount[remoteAddress] > rateForgottenAttempts);
if (index !== -1) {
deniedEmailRateLimit = (forgottenSecurity[index].count > rateForgottenAttempts);
}
if (deniedEmailRateLimit) {
errors.logError(
'Only ' + rateForgottenAttempts + ' forgotten password attempts per email every ' +
rateForgottenPeriod + ' seconds.',
'Forgotten password reset attempt failed'
);
}
if (deniedRateLimit) {
errors.logError(
'Only ' + rateForgottenAttempts + ' tries per IP address every ' + rateForgottenPeriod + ' seconds.',
'Forgotten password reset attempt failed'
);
}
if (deniedEmailRateLimit || deniedRateLimit) {
message += rateForgottenPeriod === 3600 ? ' Please wait 1 hour.' : ' Please try again later';
return next(new errors.TooManyRequestsError(message));
}
next();
},
protected: function protected(req, res, next) {
var currentTime = process.hrtime()[0],
remoteAddress = req.connection.remoteAddress,
rateProtectedPeriod = config.rateProtectedPeriod || 3600,
rateProtectedAttempts = config.rateProtectedAttempts || 10,
ipCount = '',
message = 'Too many attempts.',
deniedRateLimit = '',
password = req.body.password;
if (password) {
protectedSecurity.push({ip: remoteAddress, time: currentTime});
} else {
res.error = {
message: 'No password entered'
};
return next();
}
|
|
filter entries that are older than rateProtectedPeriod |
protectedSecurity = _.filter(protectedSecurity, function filter(logTime) {
return (logTime.time + rateProtectedPeriod > currentTime);
});
ipCount = _.chain(protectedSecurity).countBy('ip').value();
deniedRateLimit = (ipCount[remoteAddress] > rateProtectedAttempts);
if (deniedRateLimit) {
errors.logError(
'Only ' + rateProtectedAttempts + ' tries per IP address every ' + rateProtectedPeriod + ' seconds.',
'Too many login attempts.'
);
message += rateProtectedPeriod === 3600 ? ' Please wait 1 hour.' : ' Please try again later';
res.error = {
message: message
};
}
return next();
},
resetCounter: function resetCounter(email) {
loginSecurity = _.filter(loginSecurity, function filter(logTime) {
return (logTime.email !== email);
});
}
};
module.exports = spamPrevention;
|