├── .gitignore ├── .gitlab-ci.yml ├── .gitmodules ├── BUGS ├── CHANGELOG.dox ├── CMakeLists.txt ├── CTestConfig.cmake ├── GrandCentral_TB_brief_20090608.pdf ├── LICENSE ├── LICENSE.rtf ├── Modules ├── FindQtDispatch.cmake ├── Finddispatch.cmake └── Findxdispatch.cmake ├── NOTICE ├── QtDispatch.dox ├── README.dox ├── README.md ├── README.rtf ├── REQUIREMENTS.dox ├── TODO.txt ├── Tutorial.dox ├── dispatch.dox ├── docs ├── Doxyfile ├── docgen.cmake ├── doxygen.png ├── doxygen.sty ├── footer.htm ├── function.png ├── graph_legend.png ├── header.htm.in ├── header.png ├── header.tex ├── inheritance.png ├── layout.xml ├── nav_bugs.png ├── nav_downloads.png ├── nav_mailinglist.png ├── nav_news.png ├── nav_tutorial.png ├── navleft.png ├── navleft.psd ├── navpath.png ├── navpath_inv.png ├── navpath_inv.psd ├── params.png ├── project_logo.png ├── remarks.png ├── returns.png ├── seealso.png ├── styles.css ├── throws.png ├── titlebar.png ├── titlebar.psd └── xdispatch.ai ├── libblocksruntime ├── Block.h ├── Block_private.h ├── CMakeLists.txt ├── ChangeLog ├── config.h ├── data.c └── runtime.c ├── libdispatch ├── CMakeLists.txt ├── INSTALL.OLD ├── LICENSE ├── config │ ├── config.h │ └── config.h.cmake ├── include │ └── dispatch │ │ ├── base.h │ │ ├── benchmark.h │ │ ├── dispatch.h │ │ ├── group.h │ │ ├── object.h │ │ ├── once.h │ │ ├── queue.h │ │ ├── semaphore.h │ │ ├── source.h │ │ └── time.h ├── man │ ├── dispatch.3 │ ├── dispatch_after.3 │ ├── dispatch_api.3 │ ├── dispatch_apply.3 │ ├── dispatch_async.3 │ ├── dispatch_benchmark.3 │ ├── dispatch_group_create.3 │ ├── dispatch_object.3 │ ├── dispatch_once.3 │ ├── dispatch_queue_create.3 │ ├── dispatch_semaphore_create.3 │ ├── dispatch_source_create.3 │ └── dispatch_time.3 ├── platform │ ├── atomic.h │ ├── darwin │ │ ├── platform.h │ │ ├── semaphore.c │ │ └── semaphore.h │ ├── platform.h │ ├── posix │ │ └── platform.h │ └── windows │ │ ├── platform.c │ │ ├── platform.h │ │ ├── posix.h │ │ ├── posix_semaphore.h │ │ ├── pthread_cond_variables.h │ │ ├── pthread_create.h │ │ ├── pthread_mutex.h │ │ ├── pthread_rw_lock.h │ │ ├── pthread_tls.h │ │ ├── queue.h │ │ ├── stdint.h │ │ ├── threads.h │ │ └── times.h ├── src │ ├── apply.c │ ├── benchmark.c │ ├── blocks.c │ ├── blocks.h │ ├── continuation_cache.c │ ├── continuation_cache.h │ ├── debug.c │ ├── debug.h │ ├── internal.h │ ├── kevent_internal.h │ ├── legacy.c │ ├── legacy.h │ ├── object.c │ ├── object_internal.h │ ├── once.c │ ├── private.h │ ├── protocol.defs │ ├── protocol.h │ ├── protocolServer.c │ ├── protocolServer.h │ ├── protocolUser.c │ ├── queue.c │ ├── queue_internal.h │ ├── queue_kevent.c │ ├── queue_private.h │ ├── semaphore.c │ ├── semaphore_internal.h │ ├── shared_constructor.c │ ├── shims │ │ ├── compiler.h │ │ ├── getprogname.h │ │ ├── hardware.h │ │ ├── mach.c │ │ ├── malloc_zone.h │ │ ├── perfmon.h │ │ ├── time.c │ │ ├── time.h │ │ ├── tsd.c │ │ └── tsd.h │ ├── source.c │ ├── source_internal.h │ ├── source_kevent.c │ ├── source_private.h │ └── time.c └── version.rc.in ├── libkqueue ├── BUGS ├── CMakeLists.txt ├── ChangeLog ├── TODO ├── config.h.in ├── include │ └── sys │ │ └── event.h ├── kqueue.2 ├── src │ ├── common │ │ ├── alloc.h │ │ ├── debug.h │ │ ├── filter.c │ │ ├── kevent.c │ │ ├── knote.c │ │ ├── kqueue.c │ │ ├── map.c │ │ ├── private.h │ │ └── tree.h │ ├── linux │ │ ├── platform.c │ │ ├── platform.h │ │ ├── read.c │ │ ├── signal.c │ │ ├── timer.c │ │ ├── user.c │ │ ├── vnode.c │ │ └── write.c │ ├── posix │ │ ├── platform.c │ │ └── platform.h │ └── windows │ │ ├── mux.c │ │ ├── platform.c │ │ ├── platform.h │ │ ├── read.c │ │ ├── stdint.h │ │ ├── timer.c │ │ └── user.c └── test │ ├── CMakeLists.txt │ ├── common.h │ ├── kevent.c │ ├── main.c │ ├── proc.c │ ├── read.c │ ├── signal.c │ ├── test.c │ ├── timer.c │ ├── user.c │ └── vnode.c ├── libpthread_workqueue ├── BUGS ├── CMakeLists.txt ├── ChangeLog ├── LICENSE ├── TODO ├── include │ └── pthread_workqueue.h ├── pthread_workqueue.3 ├── src │ ├── api.c │ ├── debug.h │ ├── linux │ │ ├── load.c │ │ ├── platform.h │ │ ├── thread_info.c │ │ └── thread_rt.c │ ├── posix │ │ ├── manager.c │ │ ├── platform.h │ │ ├── thread_info.c │ │ └── thread_rt.c │ ├── private.h │ ├── solaris │ │ ├── load.c │ │ ├── platform.h │ │ ├── thread_info.c │ │ └── thread_rt.c │ ├── thread_info.h │ ├── thread_rt.h │ ├── windows │ │ ├── manager.c │ │ ├── platform.c │ │ ├── platform.h │ │ ├── posix_semaphore.h │ │ ├── pthread_cond.h │ │ ├── pthread_cond_variables.h │ │ ├── pthread_create.h │ │ ├── pthread_mutex.h │ │ ├── pthread_rw_lock.h │ │ ├── pthread_tls.h │ │ ├── queue.h │ │ ├── stdint.h │ │ ├── thread_info.c │ │ ├── thread_rt.c │ │ ├── threads.h │ │ └── times.h │ └── witem_cache.c └── testing │ ├── CMakeLists.txt │ ├── api │ ├── posix_semaphore.h │ ├── test.c │ └── test_api.vcxproj │ ├── idle │ └── main.c │ ├── latency │ ├── latency.c │ └── latency.h │ ├── libdispatch │ ├── Makefile │ └── dispatch_api.c │ └── witem_cache │ └── test.c ├── libqtdispatch ├── CMakeLists.txt ├── include │ └── QtDispatch │ │ ├── QBlockRunnable │ │ ├── QDispatch │ │ ├── QDispatchApplication │ │ ├── QDispatchCoreApplication │ │ ├── QDispatchGroup │ │ ├── QDispatchQueue │ │ ├── QDispatchSemaphore │ │ ├── QDispatchSource │ │ ├── QDispatchTimer │ │ ├── QIterationBlockRunnable │ │ ├── QIterationRunnable │ │ ├── QtDispatch │ │ ├── qblockrunnable.h │ │ ├── qdispatch.h │ │ ├── qdispatchapplication.h │ │ ├── qdispatchcoreapplication.h │ │ ├── qdispatchglobal.h │ │ ├── qdispatchgroup.h │ │ ├── qdispatchqueue.h │ │ ├── qdispatchsemaphore.h │ │ ├── qdispatchsource.h │ │ ├── qdispatchtimer.h │ │ ├── qiterationblockrunnable.h │ │ └── qiterationrunnable.h ├── src │ ├── qdispatch.cpp │ ├── qdispatchapplication.cpp │ ├── qdispatchapplication_mac.cpp │ ├── qdispatchapplicationprivate.h │ ├── qdispatchcoreapplication.cpp │ ├── qdispatchcoreapplication_mac.cpp │ ├── qdispatchgroup.cpp │ ├── qdispatchqueue.cpp │ ├── qdispatchsemaphore.cpp │ ├── qdispatchsource.cpp │ ├── qdispatchsourcetypes.cpp │ ├── qdispatchtimer.cpp │ ├── qrunnableoperations.cpp │ └── qrunnableoperations.h └── version.rc.in ├── libxdispatch ├── CMakeLists.txt ├── include │ └── xdispatch │ │ ├── any.h │ │ ├── base.h │ │ ├── blocks.h │ │ ├── dispatch │ │ ├── dispatch.h │ │ ├── dispatch_decl.h │ │ ├── group.h │ │ ├── lambda_dispatch.h │ │ ├── once.h │ │ ├── operation.h │ │ ├── platform.h │ │ ├── pointer.h │ │ ├── queue.h │ │ ├── semaphore.h │ │ ├── source.h │ │ ├── synchronized.h │ │ └── timer.h ├── src │ ├── base.cpp │ ├── execution.cpp │ ├── execution.h │ ├── group.cpp │ ├── once.cpp │ ├── queue.cpp │ ├── semaphore.cpp │ ├── shared_constructor.cpp │ ├── source.cpp │ ├── source_internal.cpp │ ├── source_internal.h │ ├── synchronized.cpp │ ├── timer.cpp │ └── xdispatch_internal.h └── version.rc.in ├── package ├── debian │ ├── README.Debian │ ├── README.source │ ├── changelog.in │ ├── compat │ ├── control │ ├── copyright │ ├── deb.cmake │ ├── libdispatch-dev.install │ ├── libdispatch.install │ ├── libdispatch.postrm │ ├── libqtdispatch-dev.install │ ├── libqtdispatch.install │ ├── libqtdispatch.postrm │ ├── libxdispatch-dev.install │ ├── libxdispatch.install │ ├── libxdispatch.postrm │ ├── package.sh │ ├── rules │ ├── source │ │ └── format │ ├── xdispatch-doc.install │ ├── xdispatch-doc.postinst │ └── xdispatch-doc.prerm ├── osx │ └── pkg.cmake ├── rpm │ └── rpm.cmake ├── ubuntu │ ├── README.Debian │ ├── README.source │ ├── changelog.in │ ├── compat │ ├── control │ ├── copyright │ ├── deb.cmake │ ├── libdispatch-dev.install │ ├── libdispatch.install │ ├── libdispatch.postrm │ ├── libqtdispatch-dev.install │ ├── libqtdispatch.install │ ├── libqtdispatch.postrm │ ├── libxdispatch-dev.install │ ├── libxdispatch.install │ ├── libxdispatch.postrm │ ├── package.sh │ ├── rules │ ├── source │ │ └── format │ ├── xdispatch-doc.install │ ├── xdispatch-doc.postinst │ └── xdispatch-doc.prerm ├── version.cmake └── windows │ └── zip.cmake ├── tests ├── CMakeLists.txt ├── Qt_dispatch_cascade_blocks.cpp ├── Qt_dispatch_cascade_lambda.cpp ├── Qt_dispatch_current_blocks.cpp ├── Qt_dispatch_current_lambda.cpp ├── Qt_dispatch_debug.cpp ├── Qt_dispatch_fibo.cpp ├── Qt_dispatch_group.cpp ├── Qt_dispatch_group_blocks.cpp ├── Qt_dispatch_group_lambda.cpp ├── Qt_dispatch_mainqueue_blocks.cpp ├── Qt_dispatch_mainqueue_lambda.cpp ├── Qt_dispatch_queue_blocks.cpp ├── Qt_dispatch_queue_lambda.cpp ├── Qt_dispatch_semaphore_blocks.cpp ├── Qt_dispatch_semaphore_lambda.cpp ├── Qt_dispatch_serialqueue_blocks.cpp ├── Qt_dispatch_serialqueue_lambda.cpp ├── Qt_dispatch_source_device.cpp ├── Qt_dispatch_source_network_blocks.cpp ├── Qt_dispatch_source_network_lambda.cpp ├── Qt_dispatch_source_signal_blocks.cpp ├── Qt_dispatch_source_signal_lambda.cpp ├── Qt_dispatch_timeout_blocks.cpp ├── Qt_dispatch_timeout_lambda.cpp ├── Qt_dispatch_timer.cpp ├── Qt_early_dispatch_blocks.cpp ├── Qt_early_dispatch_lambda.cpp ├── Qt_free_blocks.cpp ├── Qt_free_lambda.cpp ├── Qt_runnable_blocks.cpp ├── Qt_runnable_lambda.cpp ├── Qt_tests.h ├── atomic_operations.c ├── checks │ ├── blocks.c │ └── lambdas.cpp ├── cxx_dispatch_cascade_blocks.cpp ├── cxx_dispatch_cascade_lambda.cpp ├── cxx_dispatch_current.cpp ├── cxx_dispatch_debug.cpp ├── cxx_dispatch_fibo.cpp ├── cxx_dispatch_group.cpp ├── cxx_dispatch_group_blocks.cpp ├── cxx_dispatch_group_lambda.cpp ├── cxx_dispatch_mainqueue.cpp ├── cxx_dispatch_once.cpp ├── cxx_dispatch_once_blocks.cpp ├── cxx_dispatch_once_lambda.cpp ├── cxx_dispatch_proc_lambda.cpp ├── cxx_dispatch_queue_blocks.cpp ├── cxx_dispatch_queue_lambda.cpp ├── cxx_dispatch_read_blocks.cpp ├── cxx_dispatch_read_lambda.cpp ├── cxx_dispatch_semaphore.cpp ├── cxx_dispatch_serialqueue_blocks.cpp ├── cxx_dispatch_serialqueue_lambda.cpp ├── cxx_dispatch_source.cpp ├── cxx_dispatch_source_blocks.cpp ├── cxx_dispatch_source_lambda.cpp ├── cxx_dispatch_timer.cpp ├── cxx_free_blocks.cpp ├── cxx_free_lambda.cpp ├── cxx_synchronized.cpp ├── cxx_tests.h ├── dispatch_after.c ├── dispatch_after_blocks.c ├── dispatch_after_lambda.cpp ├── dispatch_api.c ├── dispatch_apply.c ├── dispatch_apply_blocks.c ├── dispatch_apply_lambda.cpp ├── dispatch_cascade.c ├── dispatch_debug.c ├── dispatch_drift_blocks.c ├── dispatch_group.c ├── dispatch_group_blocks.c ├── dispatch_group_lambda.cpp ├── dispatch_memory_use.c ├── dispatch_once.c ├── dispatch_pingpong_blocks.c ├── dispatch_pingpong_lambda.cpp ├── dispatch_plusplus_blocks.cpp ├── dispatch_priority.c ├── dispatch_proc_blocks.c ├── dispatch_read_blocks.c ├── dispatch_read_lambda.cpp ├── dispatch_semaphore_blocks.c ├── dispatch_semaphore_lambda.cpp ├── dispatch_serialqueue.c ├── dispatch_simpleFunction.c ├── dispatch_socket_read_write.c ├── dispatch_starfish.c ├── dispatch_sync.c ├── dispatch_timer_bit31_blocks.c ├── dispatch_timer_bit31_lambda.cpp ├── dispatch_timer_bit63_blocks.c ├── dispatch_timer_bit63_lambda.cpp ├── main.c ├── main_ios.c ├── munit │ ├── CMakeLists.txt │ ├── MUnit.h │ ├── MUnit_assert.h │ ├── MUnit_cxx.h │ ├── MUnit_runner.h │ ├── MUnit_tools.h │ ├── assert.c │ ├── list.c │ ├── list.h │ ├── private.h │ ├── runner.c │ ├── tools.c │ └── typedefs.h ├── posix_api.c ├── pthread_api.c ├── queue_finalizer.c ├── stopwatch.h ├── tests.h ├── tests.rc └── xdispatch_tests.manifest ├── xdispatch.dox └── xdispatch.sublime-project /.gitignore: -------------------------------------------------------------------------------- 1 | /*.txt.user 2 | /package/debian/changelog 3 | /package/ubuntu/changelog 4 | /*.sublime-workspace 5 | /libkqueue/config.h 6 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "build"] 2 | path = build 3 | url = ../mz-cmaketools.git 4 | -------------------------------------------------------------------------------- /BUGS: -------------------------------------------------------------------------------- 1 | * dispatching nested lambdas is currently broken in QtDispatch 2 | on MS Visual Studio 2010 SP1. See test Qt_dispatch_cascade 3 | for a workaround (using runnables) 4 | * when dispatching a lot of work items at once, the number of 5 | threads on windows and linux will explode but decrease quite 6 | fast again 7 | * periodic timers have an increasing delay the longer they run 8 | (see dispatch_drift test). This might be due to an implementation 9 | error of EVT_FILT_TIMER on windows. -------------------------------------------------------------------------------- /CTestConfig.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # CTestConfig.cmake 3 | # 4 | # Copyright (c) 2011-2018 MLBA-Team 5 | # All rights reserved. 6 | # 7 | # @LICENSE_HEADER_START@ 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # @LICENSE_HEADER_END@ 20 | # 21 | 22 | ## This file should be placed in the root directory of your project. 23 | ## Then modify the CMakeLists.txt file in the root directory of your 24 | ## project to incorporate the testing dashboard. 25 | ## # The following are required to uses Dart and the Cdash dashboard 26 | ## ENABLE_TESTING() 27 | ## INCLUDE(CTest) 28 | set(CTEST_PROJECT_NAME "XDispatch") 29 | set(CTEST_NIGHTLY_START_TIME "00:00:00 EST") 30 | 31 | set(CTEST_DROP_METHOD "http") 32 | set(CTEST_DROP_SITE "dash.s.emzeat.de") 33 | set(CTEST_DROP_LOCATION "/submit.php?project=XDispatch") 34 | set(CTEST_DROP_SITE_CDASH TRUE) 35 | -------------------------------------------------------------------------------- /GrandCentral_TB_brief_20090608.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/GrandCentral_TB_brief_20090608.pdf -------------------------------------------------------------------------------- /QtDispatch.dox: -------------------------------------------------------------------------------- 1 | /** 2 | @defgroup qtdispatch libQtDispatch 3 | 4 | QtDispatch is an additional Qt Module building on QtCore and providing a custom Qt adapted interface to use \ref dispatch. 5 | 6 | This interface is fully compatible with the generic C++ interface provided by 7 | \ref xdispatch. 8 | 9 | As integration into Qt, it is possible to dispatch QRunnables onto groups and queues the same way as when executing them on a QThreadPool. Going along with that we added 10 | QBlockRunnable, a simple QRunnable created by passing an individual block. 11 | 12 | For integrating the main queue into your Qt Application there is a QDispatchApplication which can be used as a drop-in replacement to QApplication. It will call xdispatch::exec() internally and ensure that all work dispatched to the main queue is executed on the main/gui thread. That way it is very easy to send gui updates to the main thread. All other functionality is equal to that of QApplication. 13 | 14 | @section qt_use Usage 15 | 16 | You can use QtDispach (in case you have Qt > 4.6 available on your system) by including the QtDispatch header or one of the individual modules - this will automatically include all other needed headers as well. Below you find a list of the available classes. 17 | - QDispatch 18 | - QDispatchQueue 19 | - QDispatchGroup 20 | - QDispatchSemaphore 21 | - QBlockRunnable 22 | - QIterationBlockRunnable 23 | - QIterationRunnable 24 | - QDispatchCoreApplication 25 | - QDispatchApplication 26 | - QDispatchSource 27 | - QDispatchSourceType 28 | 29 | The corresponding headers have the same name and can be included all by once using 30 | @code 31 | #include 32 | @endcode 33 | 34 | Please link your program with qtdispatch and xdispatch. 35 | */ 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | _This project is no longer actively maintained. While it should be functional 2 | in general, the codebase will not receive any bugfixes moving forward. You might want to have a look at the successor project 3 | [xdispatch2](https://github.com/emzeat/xdispatch2) though._ 4 | 5 | xdispatch 6 | ================= 7 | 8 | XDispatch provides the power of Grand Central Dispatch not only on Mac OS 10.6+ 9 | but also on Windows and Linux. The XDispatch framework consists of three libraries: 10 | * libdispatch 11 | * libxdispatch 12 | * libqtdispatch 13 | 14 | Feel free to fork it and change it as you like. We always welcome any bugfixes or 15 | improvements to our current code base. 16 | 17 | 18 | Usage 19 | ----- 20 | 21 | Please see the documentation at http://opensource.mlba-team.de/xdispatch for details. 22 | -------------------------------------------------------------------------------- /dispatch.dox: -------------------------------------------------------------------------------- 1 | /** 2 | @defgroup dispatch libdispatch 3 | 4 | The library libdispatch is an abstract model for expressing concurrency via simple but powerful API. 5 | 6 | At the core, libdispatch provides serial FIFO queues to which blocks may be 7 | submitted. Blocks submitted to these dispatch queues are invoked on a pool 8 | of threads fully managed by the system. No guarantee is made regarding 9 | which thread a block will be invoked on; however, it is guaranteed that only 10 | one block submitted to the FIFO dispatch queue will be invoked at a time. 11 | 12 | When multiple queues have blocks to be processed, the system is free to 13 | allocate additional threads to invoke the blocks concurrently. When the 14 | queues become empty, these threads are automatically released. 15 | 16 | @section d_use Usage 17 | 18 | All header files needed for using libdispatch can be included by typing 19 | @code 20 | #include 21 | @endcode 22 | You will need to link against the dispatch library. 23 | 24 | */ 25 | -------------------------------------------------------------------------------- /docs/doxygen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/doxygen.png -------------------------------------------------------------------------------- /docs/footer.htm: -------------------------------------------------------------------------------- 1 |
2 | Generated on $datetime for $projectname by Doxygen $doxygenversion
3 | © 2010-2014 MLBA (about | privacy) All Rights reserved.
4 | 5 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /docs/function.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/function.png -------------------------------------------------------------------------------- /docs/graph_legend.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/graph_legend.png -------------------------------------------------------------------------------- /docs/header.htm.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | $title 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 |
XDispatch ${XDISPATCH_VERSION}
14 | 42 | -------------------------------------------------------------------------------- /docs/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/header.png -------------------------------------------------------------------------------- /docs/header.tex: -------------------------------------------------------------------------------- 1 | \documentclass[a4paper]{book} 2 | \usepackage{a4wide} 3 | \usepackage{makeidx} 4 | \usepackage{fancyhdr} 5 | \usepackage{graphicx} 6 | \usepackage{multicol} 7 | \usepackage{float} 8 | \usepackage{textcomp} 9 | \usepackage{alltt} 10 | \usepackage{longtable} 11 | %\usepackage{times} 12 | \usepackage[scaled]{helvet} 13 | \renewcommand*\familydefault{\sfdefault} %% Only if the base font of the document is to be sans serif 14 | \usepackage{ifpdf} 15 | \ifpdf 16 | \usepackage[pdftex, 17 | pagebackref=true, 18 | colorlinks=true, 19 | linkcolor=blue, 20 | unicode 21 | ]{hyperref} 22 | \else 23 | \usepackage[ps2pdf, 24 | pagebackref=true, 25 | colorlinks=true, 26 | linkcolor=blue, 27 | unicode 28 | ]{hyperref} 29 | \usepackage{pspicture} 30 | \fi 31 | \usepackage[utf8]{inputenc} 32 | \usepackage{doxygen} 33 | \makeindex 34 | \setcounter{tocdepth}{3} 35 | \renewcommand{\footrulewidth}{0.4pt} 36 | \begin{document} 37 | \begin{titlepage} 38 | \vspace*{7cm} 39 | \begin{center} 40 | \includegraphics{SG_Logo_256.png}\\\mbox{}\\ 41 | {\Large\Large SceneGraph Library Documentation}\\ 42 | \vspace*{0.5cm} 43 | {\small MMSI 1 Project Edition}\\ 44 | \end{center} 45 | \end{titlepage} 46 | \clearemptydoublepage 47 | \pagenumbering{roman} 48 | \tableofcontents 49 | \clearemptydoublepage 50 | \pagenumbering{arabic} 51 | -------------------------------------------------------------------------------- /docs/inheritance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/inheritance.png -------------------------------------------------------------------------------- /docs/nav_bugs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/nav_bugs.png -------------------------------------------------------------------------------- /docs/nav_downloads.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/nav_downloads.png -------------------------------------------------------------------------------- /docs/nav_mailinglist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/nav_mailinglist.png -------------------------------------------------------------------------------- /docs/nav_news.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/nav_news.png -------------------------------------------------------------------------------- /docs/nav_tutorial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/nav_tutorial.png -------------------------------------------------------------------------------- /docs/navleft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/navleft.png -------------------------------------------------------------------------------- /docs/navleft.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/navleft.psd -------------------------------------------------------------------------------- /docs/navpath.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/navpath.png -------------------------------------------------------------------------------- /docs/navpath_inv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/navpath_inv.png -------------------------------------------------------------------------------- /docs/navpath_inv.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/navpath_inv.psd -------------------------------------------------------------------------------- /docs/params.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/params.png -------------------------------------------------------------------------------- /docs/project_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/project_logo.png -------------------------------------------------------------------------------- /docs/remarks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/remarks.png -------------------------------------------------------------------------------- /docs/returns.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/returns.png -------------------------------------------------------------------------------- /docs/seealso.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/seealso.png -------------------------------------------------------------------------------- /docs/throws.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/throws.png -------------------------------------------------------------------------------- /docs/titlebar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/titlebar.png -------------------------------------------------------------------------------- /docs/titlebar.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/titlebar.psd -------------------------------------------------------------------------------- /docs/xdispatch.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mlba-team/xdispatch/6f5301f3df335ceb81cf80455a7484caa5e03ffb/docs/xdispatch.ai -------------------------------------------------------------------------------- /libblocksruntime/ChangeLog: -------------------------------------------------------------------------------- 1 | 2010-06-24 Mark Heily 2 | 3 | * Initial release of libBlocksRuntime from complier-rt r104787 4 | 5 | -------------------------------------------------------------------------------- /libblocksruntime/config.h: -------------------------------------------------------------------------------- 1 | /* AUTOMATICALLY GENERATED -- DO NOT EDIT */ 2 | 3 | #define HAVE_SYNC_BOOL_COMPARE_AND_SWAP_INT 1 4 | #define HAVE_SYNC_BOOL_COMPARE_AND_SWAP_LONG 1 5 | #define PROGRAM "libBlocksRuntime" 6 | #define VERSION "0.1" 7 | #define TARGET "linux" 8 | #define CFLAGS "-DBlocksRuntime_EXPORTS -fPIC -std=c99 -Wall -Wextra -W -pedantic -Wno-unused-parameter" 9 | -------------------------------------------------------------------------------- /libdispatch/include/dispatch/dispatch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008-2009 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_PUBLIC__ 22 | #define __DISPATCH_PUBLIC__ 23 | 24 | /** 25 | * @addtogroup dispatch 26 | * @{ 27 | */ 28 | 29 | #ifdef __APPLE__ 30 | #include 31 | #include 32 | #endif 33 | 34 | #ifndef __DISPATCH_BEGIN_DECLS 35 | #if defined(__cplusplus) 36 | # define __DISPATCH_BEGIN_DECLS extern "C" { 37 | # define __DISPATCH_END_DECLS } 38 | # else 39 | # define __DISPATCH_BEGIN_DECLS 40 | # define __DISPATCH_END_DECLS 41 | # endif 42 | #endif 43 | 44 | #ifndef __DISPATCH_BUILD_FEATURE 45 | # define __DISPATCH_BUILD_FEATURE(X) X 46 | #endif 47 | 48 | #include 49 | #if !defined(__GNUC__) && defined(_WIN32) && _MSC_VER < 1600 50 | typedef signed __int64 int64_t; 51 | typedef unsigned __int64 uint64_t; 52 | #else 53 | # include 54 | #endif 55 | #ifndef _WIN32 56 | # include 57 | #endif 58 | 59 | #define DISPATCH_API_VERSION 20090501+080 60 | 61 | 62 | #ifndef __DISPATCH_INDIRECT__ 63 | #define __DISPATCH_INDIRECT__ 64 | #endif 65 | 66 | #include "base.h" 67 | #include "object.h" 68 | #include "time.h" 69 | #include "queue.h" 70 | #include "source.h" 71 | #include "group.h" 72 | #include "semaphore.h" 73 | #include "once.h" 74 | 75 | #undef __DISPATCH_INDIRECT__ 76 | 77 | /** @} */ 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /libdispatch/man/dispatch.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 2008-2009 Apple Inc. All rights reserved. 2 | .Dd May 1, 2009 3 | .Dt dispatch 3 4 | .Os Darwin 5 | .Sh NAME 6 | .Nm dispatch 7 | .Nd the dispatch framework 8 | .Sh SYNOPSIS 9 | .Fd #include 10 | .Sh DESCRIPTION 11 | The dispatch framework allows blocks to be scheduled for asynchronous and 12 | concurrent execution via the core functions described in 13 | .Xr dispatch_async 3 and 14 | .Xr dispatch_apply 3 . 15 | .Pp 16 | Dispatch queues are the basic units of organization of blocks. Several queues 17 | are created by default, and applications may create additional queues for their 18 | own use. See 19 | .Xr dispatch_queue_create 3 20 | for more information. 21 | .Pp 22 | Dispatch groups allow applications to track the progress of blocks submitted to 23 | queues and take action when the blocks complete. See 24 | .Xr dispatch_group_create 3 25 | for more information. 26 | .Pp 27 | The dispatch framework also provides functions to monitor underlying system 28 | events and automatically submit event handler blocks to dispatch queues. 29 | .Sh SEE ALSO 30 | .Xr dispatch_after 3 , 31 | .Xr dispatch_api 3 , 32 | .Xr dispatch_apply 3 , 33 | .Xr dispatch_async 3 , 34 | .Xr dispatch_benchmark 3 , 35 | .Xr dispatch_group_create 3 , 36 | .Xr dispatch_object 3 , 37 | .Xr dispatch_once 3 , 38 | .Xr dispatch_queue_create 3 , 39 | .Xr dispatch_semaphore_create 3 , 40 | .Xr dispatch_source_create 3 , 41 | .Xr dispatch_time 3 42 | -------------------------------------------------------------------------------- /libdispatch/man/dispatch_after.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 2008-2009 Apple Inc. All rights reserved. 2 | .Dd May 1, 2009 3 | .Dt dispatch_after 3 4 | .Os Darwin 5 | .Sh NAME 6 | .Nm dispatch_after 7 | .Nd schedule blocks for deferred execution 8 | .Sh SYNOPSIS 9 | .Fd #include 10 | .Ft void 11 | .Fo dispatch_after 12 | .Fa "dispatch_time_t when" "dispatch_queue_t queue" "void (^block)(void)" 13 | .Fc 14 | .Ft void 15 | .Fo dispatch_after_f 16 | .Fa "dispatch_time_t when" "dispatch_queue_t queue" "void *context" "void (*function)(void *)" 17 | .Fc 18 | .Sh DESCRIPTION 19 | The 20 | .Fn dispatch_after 21 | function submits the 22 | .Fa block 23 | to the given 24 | .Fa queue 25 | at the time specified by the 26 | .Fa when 27 | parameter. 28 | The 29 | .Fa when 30 | parameter is a value created by 31 | .Fn dispatch_time 32 | or 33 | .Fn dispatch_walltime . 34 | .Pp 35 | For a more detailed description about submitting blocks to queues, see 36 | .Xr dispatch_async 3 . 37 | .Sh CAVEATS 38 | Specifying 39 | .Vt DISPATCH_TIME_NOW 40 | as the 41 | .Fa when 42 | parameter 43 | is supported, but is not as efficient as calling 44 | .Fn dispatch_async . 45 | The result of passing 46 | .Vt DISPATCH_TIME_FOREVER 47 | as the 48 | .Fa when 49 | parameter is undefined. 50 | .Sh FUNDAMENTALS 51 | The 52 | .Fn dispatch_after 53 | function is a wrapper around 54 | .Fn dispatch_after_f . 55 | .Sh SEE ALSO 56 | .Xr dispatch 3 , 57 | .Xr dispatch_async 3 , 58 | .Xr dispatch_time 3 59 | -------------------------------------------------------------------------------- /libdispatch/man/dispatch_api.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 2008-2009 Apple Inc. All rights reserved. 2 | .Dd May 1, 2009 3 | .Dt dispatch_api 3 4 | .Os Darwin 5 | .Sh NAME 6 | .Nm dispatch_api 7 | .Nd Designing API using dispatch 8 | .Sh DESCRIPTION 9 | The following is a brief summary of some of the common design patterns to 10 | consider when designing and implementing API in terms of dispatch queues 11 | and blocks. 12 | .Pp 13 | A general recommendation is to allow both a callback block and target dispatch 14 | queue to be specified. This gives the application the greatest flexibility in 15 | handling asynchronous events. 16 | .Pp 17 | It's also recommended that interfaces take only a single block as the last 18 | parameter. This is both for consistency across projects, as well as the visual 19 | aesthetics of multiline blocks that are declared inline. The dispatch queue to 20 | which the block will be submitted should immediately precede the block argument 21 | (second-to-last argument). For example: 22 | .Pp 23 | .Bd -literal -offset indent 24 | read_async(file, callback_queue, ^{ 25 | printf("received callback.\\n"); 26 | }); 27 | .Ed 28 | .Pp 29 | When function pointer alternatives to interfaces that take blocks are provided, 30 | the argument order of the function signature should be identical to the block 31 | variant; with the exception that the block argument is replaced with a context 32 | pointer, and a new last parameter is added, which is the function to call. 33 | .Pp 34 | The function based callback should pass the context pointer as the first 35 | argument, and the subsequent arguments should be identical to the block based 36 | variant (albeit offset by one in order). 37 | .Pp 38 | It is also important to use consistent naming. The dispatch API, for example, 39 | uses the suffix "_f" for function based variants. 40 | .Pp 41 | .Sh SEE ALSO 42 | .Xr dispatch 3 , 43 | .Xr dispatch_async 3 , 44 | .Xr dispatch_queue_create 3 45 | -------------------------------------------------------------------------------- /libdispatch/man/dispatch_benchmark.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 2008-2009 Apple Inc. All rights reserved. 2 | .Dd May 1, 2009 3 | .Dt dispatch_benchmark 3 4 | .Os Darwin 5 | .Sh NAME 6 | .Nm dispatch_benchmark 7 | .Nd Measures block execution time 8 | .Sh SYNOPSIS 9 | .Fd #include 10 | .Ft uint64_t 11 | .Fo dispatch_benchmark 12 | .Fa "size_t count" "void (^block)(void)" 13 | .Fc 14 | .Ft uint64_t 15 | .Fo dispatch_benchmark_f 16 | .Fa "size_t count" "void *context" "void (*function)(void *)" 17 | .Fc 18 | .Sh DESCRIPTION 19 | The 20 | .Fn dispatch_benchmark 21 | function executes the given 22 | .Fa block 23 | multiple times according to the 24 | .Fa count 25 | variable and then returns the average number of nanoseconds per execution. 26 | This function is for debugging and performance analysis work. 27 | For the best 28 | results, pass a high count value to 29 | .Fn dispatch_benchmark . 30 | When benchmarking concurrent code, please compare the 31 | serial version of the code against the concurrent version, and compare the 32 | concurrent version on different classes of hardware. 33 | Please look for inflection 34 | points with various data sets and keep the following facts in mind: 35 | .Pp 36 | .Bl -bullet -offset indent -compact 37 | .It 38 | Code bound by computational bandwidth may be inferred by proportional 39 | changes in performance as concurrency is increased. 40 | .It 41 | Code bound by memory bandwidth may be inferred by negligible changes in 42 | performance as concurrency is increased. 43 | .It 44 | Code bound by critical sections may be inferred by retrograde changes in 45 | performance as concurrency is increased. 46 | .Bl -bullet -offset indent -compact 47 | .It 48 | Intentional: locks, mutexes, and condition variables. 49 | .It 50 | Accidental: unrelated and frequently modified data on the same cache-line. 51 | .El 52 | .El 53 | .Sh RETURN VALUE 54 | The 55 | .Fn dispatch_benchmark 56 | function returns the average number of nanoseconds the given block takes to 57 | execute. 58 | .Sh SEE ALSO 59 | .Xr dispatch 3 60 | -------------------------------------------------------------------------------- /libdispatch/man/dispatch_once.3: -------------------------------------------------------------------------------- 1 | .\" Copyright (c) 2008-2009 Apple Inc. All rights reserved. 2 | .Dd May 1, 2009 3 | .Dt dispatch_once 3 4 | .Os Darwin 5 | .Sh NAME 6 | .Nm dispatch_once 7 | .Nd execute a block only once 8 | .Sh SYNOPSIS 9 | .Fd #include 10 | .Ft void 11 | .Fo dispatch_once 12 | .Fa "dispatch_once_t *predicate" "void (^block)(void)" 13 | .Fc 14 | .Ft void 15 | .Fo dispatch_once_f 16 | .Fa "dispatch_once_t *predicate" "void *context" "void (*function)(void *)" 17 | .Fc 18 | .Sh DESCRIPTION 19 | The 20 | .Fn dispatch_once 21 | function provides a simple and efficient mechanism to run an initializer 22 | exactly once, similar to 23 | .Xr pthread_once 3 . 24 | Well designed code hides the use of lazy initialization. 25 | For example: 26 | .Bd -literal 27 | FILE *getlogfile(void) 28 | { 29 | static dispatch_once_t pred; 30 | static FILE *logfile; 31 | 32 | dispatch_once(&pred, ^{ 33 | logfile = fopen(MY_LOG_FILE, "a"); 34 | }); 35 | 36 | return logfile; 37 | } 38 | .Ed 39 | .Pp 40 | .Sh FUNDAMENTALS 41 | The 42 | .Fn dispatch_once 43 | function is a wrapper around 44 | .Fn dispatch_once_f . 45 | .Sh SEE ALSO 46 | .Xr dispatch 3 47 | -------------------------------------------------------------------------------- /libdispatch/platform/darwin/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2012 MLBA-Team. All rights reserved. 3 | * 4 | * @MLBA_OPEN_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 | * @MLBA_OPEN_LICENSE_HEADER_END@ 19 | */ 20 | 21 | #ifndef DARWIN_PLATFORM_H_ 22 | #define DARWIN_PLATFORM_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | 52 | #include "semaphore.h" 53 | 54 | #endif /* DARWIN_PLATFORM_H_ */ 55 | -------------------------------------------------------------------------------- /libdispatch/platform/darwin/semaphore.c: -------------------------------------------------------------------------------- 1 | 2 | #include "semaphore.h" 3 | 4 | int sem_timedwait(sem_t * sem, const struct timespec * timeout){ 5 | int res; 6 | dispatch_time_t until = dispatch_walltime(timeout, 0); 7 | while( (res = sem_trywait(sem)) == EAGAIN 8 | && until < dispatch_time(DISPATCH_TIME_NOW,0)) 9 | sleep(1); 10 | 11 | if (until >= dispatch_time(DISPATCH_TIME_NOW,0)) 12 | return ETIMEDOUT; 13 | 14 | return res; 15 | } 16 | -------------------------------------------------------------------------------- /libdispatch/platform/darwin/semaphore.h: -------------------------------------------------------------------------------- 1 | #ifndef DARWIN_SEMAPHORE_H_ 2 | #define DARWIN_SEMAPHORE_H_ 3 | 4 | int sem_timedwait(sem_t * sem, const struct timespec * timeout); 5 | 6 | #endif /* DARWIN_SEMAPHORE_H_ */ -------------------------------------------------------------------------------- /libdispatch/platform/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 MLBA-Team. All rights reserved. 3 | * 4 | * @MLBA_OPEN_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 | * @MLBA_OPEN_LICENSE_HEADER_END@ 19 | */ 20 | 21 | #ifndef PLATFORM_H_ 22 | #define PLATFORM_H_ 23 | 24 | #if defined(__cplusplus) 25 | extern "C" { 26 | #endif 27 | 28 | #if _WIN32 29 | # include "windows/platform.h" 30 | #elif __APPLE__ 31 | # include "darwin/platform.h" 32 | #else /* POSIX */ 33 | # include "posix/platform.h" 34 | #endif 35 | 36 | #include "atomic.h" 37 | 38 | #if defined(__cplusplus) 39 | } 40 | #endif 41 | 42 | #endif /* PLATFORM_H_ */ 43 | -------------------------------------------------------------------------------- /libdispatch/platform/posix/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 MLBA. All rights reserved. 3 | * 4 | * @MLBA_OPEN_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 | * @MLBA_OPEN_LICENSE_HEADER_END@ 19 | */ 20 | 21 | #ifndef POSIX_PLATFORM_H_ 22 | #define POSIX_PLATFORM_H_ 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | 43 | #ifndef FD_COPY 44 | #define FD_COPY(f, t) (void)(*(t) = *(f)) 45 | #endif 46 | 47 | #endif /* POSIX_PLATFORM_H_ */ 48 | -------------------------------------------------------------------------------- /libdispatch/platform/windows/platform.c: -------------------------------------------------------------------------------- 1 | 2 | #include "platform.h" 3 | 4 | DECL_WIN_PTHREAD_VARIABLES; -------------------------------------------------------------------------------- /libdispatch/platform/windows/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 MLBA. All rights reserved. 3 | * 4 | * @MLBA_OPEN_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 | * @MLBA_OPEN_LICENSE_HEADER_END@ 19 | */ 20 | 21 | #ifndef WINDOWS_PLATFORM_H_ 22 | #define WINDOWS_PLATFORM_H_ 23 | 24 | /* Workaround for a bug in VS2008 */ 25 | #if _MSC_VER < 1600 26 | # ifndef _IVEC_H_INCLUDED 27 | # define _IVEC_H_INCLUDED 1 28 | # endif 29 | # ifndef _FVEC_H_INCLUDED 30 | # define _FVEC_H_INCLUDED 1 31 | # endif 32 | # ifndef _DVEC_H_INCLUDED 33 | # define _DVEC_H_INCLUDED 1 34 | # endif 35 | #endif 36 | 37 | #include "posix.h" 38 | #include "threads.h" 39 | #include "queue.h" 40 | 41 | #if !defined(__GNUC__) && _MSC_VER < 1600 42 | # include "stdint.h" 43 | #else 44 | # include 45 | #endif 46 | 47 | #endif /* WINDOWS_PLATFORM_H_ */ 48 | -------------------------------------------------------------------------------- /libdispatch/platform/windows/posix_semaphore.h: -------------------------------------------------------------------------------- 1 | #ifndef DISPATCH_WIN_POSIX_SEMAPHORE_ 2 | #define DISPATCH_WIN_POSIX_SEMAPHORE_ 3 | 4 | typedef HANDLE sem_t; 5 | 6 | static int sem_init(sem_t * sem, int shared, unsigned int val) 7 | { 8 | *sem = CreateSemaphore(0, val, 1, 0); 9 | // TODO: Proper error handling 10 | return *sem == 0; 11 | } 12 | 13 | static inline int sem_destroy(sem_t* s) 14 | { 15 | return CloseHandle(s) != 1; 16 | } 17 | 18 | static inline int sem_post(sem_t* s) 19 | { 20 | return !ReleaseSemaphore(s, 1, 0); 21 | } 22 | 23 | static inline int sem_wait(sem_t* s) 24 | { 25 | return WaitForSingleObject(s, INFINITE) == WAIT_FAILED; 26 | } 27 | 28 | static int sem_timedwait(sem_t * sem, const struct timespec * timeout) 29 | { 30 | DWORD duration = (DWORD)(timeout->tv_nsec / 1000000) + (DWORD)(timeout->tv_sec * 1000); 31 | 32 | switch(WaitForSingleObject(sem,duration) ){ 33 | case WAIT_TIMEOUT: 34 | return ETIMEDOUT; 35 | case WAIT_FAILED: 36 | return EINVAL; 37 | default: 38 | return 0; 39 | } 40 | } 41 | 42 | #endif /* DISPATCH_WIN_POSIX_SEMAPHORE_ */ 43 | -------------------------------------------------------------------------------- /libdispatch/platform/windows/threads.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Apple Inc. All rights reserved. 3 | * Copyright (c) 2011 MLBA. All rights reserved. 4 | * Copyright (c) 2010 Mark Heily 5 | * 6 | * @APPLE_APACHE_LICENSE_HEADER_START@ 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | * @APPLE_APACHE_LICENSE_HEADER_END@ 21 | */ 22 | 23 | #ifndef THREADS_WIN_H_ 24 | #define THREADS_WIN_H_ 25 | 26 | /* 27 | Needs to be set to ensure we are using only function calls 28 | availabe on windows XP and later. (Windows Vista when not set) 29 | */ 30 | #define TARGET_OS_WIN_XP 1 31 | 32 | #include "pthread_mutex.h" 33 | #include "pthread_create.h" 34 | #include "pthread_cond_variables.h" 35 | #include "pthread_tls.h" 36 | #include "posix_semaphore.h" 37 | 38 | /* 39 | currently this is borrowed from linux, we will see if this needs to become adapted 40 | */ 41 | #define NSIG 32 42 | 43 | /* signals */ 44 | typedef int sigset_t; 45 | 46 | #endif /* THREADS_WIN_H_ */ 47 | -------------------------------------------------------------------------------- /libdispatch/src/blocks.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008-2009 Apple Inc. All rights reserved. 3 | * Copyright (c) 2011-2013 MLBA-Team. All rights reserved. 4 | * 5 | * @MLBA_OPEN_LICENSE_HEADER_START@ 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * @MLBA_OPEN_LICENSE_HEADER_END@ 20 | */ 21 | 22 | #include "internal.h" 23 | 24 | #ifdef __BLOCKS__ 25 | 26 | #ifdef _dispatch_Block_copy 27 | # undef _dispatch_Block_copy 28 | #endif 29 | 30 | dispatch_block_t _dispatch_Block_copy(dispatch_block_t db) 31 | { 32 | dispatch_block_t rval; 33 | 34 | while (!(rval = Block_copy(db))) { 35 | sleep(1); 36 | } 37 | 38 | return rval; 39 | } 40 | 41 | #define _dispatch_Block_copy(x) ((typeof(x))_dispatch_Block_copy(x)) 42 | 43 | void 44 | _dispatch_call_block_and_release(void *block) 45 | { 46 | void (^b)(void) = block; 47 | b(); 48 | Block_release(b); 49 | } 50 | 51 | void 52 | _dispatch_call_block_and_release2(void *block, void *ctxt) 53 | { 54 | void (^b)(void*) = block; 55 | b(ctxt); 56 | Block_release(b); 57 | } 58 | 59 | #endif /* __BLOCKS__ */ 60 | -------------------------------------------------------------------------------- /libdispatch/src/blocks.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008-2009 Apple Inc. All rights reserved. 3 | * Copyright (c) 2011-2013 MLBA-Team. All rights reserved. 4 | * 5 | * @MLBA_OPEN_LICENSE_HEADER_START@ 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * @MLBA_OPEN_LICENSE_HEADER_END@ 20 | */ 21 | 22 | #ifndef __HELP_BLOCKS_H_ 23 | #define __HELP_BLOCKS_H_ 24 | 25 | #ifdef __BLOCKS__ 26 | dispatch_block_t 27 | _dispatch_Block_copy(dispatch_block_t db); 28 | #define _dispatch_Block_copy(x) ((typeof(x))_dispatch_Block_copy(x)) 29 | 30 | void 31 | _dispatch_call_block_and_release(void *block); 32 | 33 | void 34 | _dispatch_call_block_and_release2(void *block, void *ctxt); 35 | 36 | #endif /* __BLOCKS__ */ 37 | 38 | #endif /* __HELP_BLOCKS_H_ */ 39 | -------------------------------------------------------------------------------- /libdispatch/src/kevent_internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008-2009 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 | /* 22 | * IMPORTANT: This header file describes INTERNAL interfaces to libdispatch 23 | * which are subject to change in future releases of Mac OS X. Any applications 24 | * relying on these interfaces WILL break. 25 | */ 26 | 27 | #ifndef __DISPATCH_KEVENT_INTERNAL__ 28 | #define __DISPATCH_KEVENT_INTERNAL__ 29 | 30 | #include "internal.h" 31 | 32 | struct dispatch_kevent_s { 33 | TAILQ_ENTRY(dispatch_kevent_s) dk_list; 34 | TAILQ_HEAD(, dispatch_source_s) dk_sources; 35 | struct kevent dk_kevent; 36 | }; 37 | 38 | extern const struct dispatch_source_vtable_s _dispatch_source_kevent_vtable; 39 | 40 | #if DISPATCH_DEBUG 41 | void dispatch_debug_kevents(struct kevent* kev, size_t count, const char* str); 42 | #else 43 | # define dispatch_debug_kevents(x, y, z) 44 | #endif 45 | 46 | void _dispatch_source_drain_kevent(struct kevent *); 47 | void _dispatch_update_kq(const struct kevent *); 48 | 49 | 50 | #endif /* __DISPATCH_KEVENT_INTERNAL__ */ 51 | -------------------------------------------------------------------------------- /libdispatch/src/shims/compiler.h: -------------------------------------------------------------------------------- 1 | #ifndef DISPATCH_COMPILER_H_ 2 | #define DISPATCH_COMPILER_H_ 3 | 4 | #ifndef DISPATCH_NOINLINE 5 | # if __GNUC__ 6 | # define DISPATCH_NOINLINE __attribute__((noinline)) 7 | # else 8 | # define DISPATCH_NOINLINE 9 | # endif 10 | #endif 11 | 12 | #ifndef DISPATCH_INLINE 13 | # if __GNUC__ 14 | # define DISPATCH_INLINE __attribute__((always_inline)) 15 | # else 16 | # define DISPATCH_INLINE 17 | # endif 18 | #endif 19 | 20 | #ifndef DISPATCH_UNUSED 21 | # if __GNUC__ 22 | # define DISPATCH_UNUSED __attribute__((unused)) 23 | # else 24 | # define DISPATCH_UNUSED 25 | # endif 26 | #endif 27 | 28 | #ifndef DISPATCH_NORETURN 29 | # if __GNUC__ 30 | # define DISPATCH_NORETURN __attribute__((__noreturn__)) 31 | # else 32 | # define DISPATCH_NORETURN 33 | # endif 34 | #endif 35 | 36 | #endif /* DISPATCH_COMPILER_H_ */ 37 | -------------------------------------------------------------------------------- /libdispatch/src/shims/getprogname.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2010 Mark Heily 3 | * All rights reserved. 4 | * 5 | * @APPLE_APACHE_LICENSE_HEADER_START@ 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * @APPLE_APACHE_LICENSE_HEADER_END@ 20 | */ 21 | 22 | #ifndef __DISPATCH_SHIMS_GETPROGNAME__ 23 | #define __DISPATCH_SHIMS_GETPROGNAME__ 24 | 25 | #if !HAVE_GETPROGNAME 26 | 27 | static inline const char * 28 | getprogname(void) 29 | { 30 | # if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME 31 | return program_invocation_short_name; 32 | #elif HAVE_GETEXECNAME 33 | return getexecname(); 34 | # elif TARGET_OS_WIN32 35 | return 0; 36 | # else 37 | # error getprogname(3) is not available on this platform 38 | # endif 39 | } 40 | 41 | #endif /* HAVE_GETPROGNAME */ 42 | 43 | #endif /* __DISPATCH_SHIMS_GETPROGNAME__ */ 44 | -------------------------------------------------------------------------------- /libdispatch/src/shims/hardware.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008-2009 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 | /* 22 | * IMPORTANT: This header file describes INTERNAL interfaces to libdispatch 23 | * which are subject to change in future releases of Mac OS X. Any applications 24 | * relying on these interfaces WILL break. 25 | */ 26 | 27 | #ifndef __DISPATCH_HW_SHIMS__ 28 | #define __DISPATCH_HW_SHIMS__ 29 | 30 | /* x86 has a 64 byte cacheline */ 31 | #define DISPATCH_CACHELINE_SIZE 64 32 | #define ROUND_UP_TO_CACHELINE_SIZE(x) (((x) + (DISPATCH_CACHELINE_SIZE - 1)) & ~(DISPATCH_CACHELINE_SIZE - 1)) 33 | #define ROUND_UP_TO_VECTOR_SIZE(x) (((x) + 15) & ~15) 34 | 35 | #if defined(__i386__) || defined(__x86_64__) 36 | #define _dispatch_hardware_pause() asm("pause") 37 | #define _dispatch_debugger() asm("int3") 38 | #elif defined(_M_X64) 39 | #define _dispatch_hardware_pause() Sleep(0) 40 | #define _dispatch_debugger() __asm { int3 } 41 | #elif defined(_M_IX86) 42 | #define _dispatch_hardware_pause() __asm { pause } 43 | #define _dispatch_debugger() __asm { int3 } 44 | #else 45 | #define _dispatch_hardware_pause() asm("") 46 | #define _dispatch_debugger() asm("trap") 47 | #endif 48 | 49 | #if TARGET_OS_WIN32 && !defined(__GNUC__) 50 | # define _dispatch_hardware_crash() __debugbreak() 51 | #else 52 | # define _dispatch_hardware_crash() __builtin_trap() 53 | #endif 54 | 55 | 56 | #endif /* __DISPATCH_HW_SHIMS__ */ 57 | -------------------------------------------------------------------------------- /libdispatch/src/shims/time.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008-2009 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 | #include "../internal.h" 22 | 23 | // for architectures that don't always return mach_absolute_time() in nanoseconds 24 | #if !(defined(__i386__) || defined(__x86_64__)) || !HAVE_MACH_ABSOLUTE_TIME 25 | _dispatch_host_time_data_s _dispatch_host_time_data; 26 | 27 | void 28 | _dispatch_get_host_time_init(void *context DISPATCH_UNUSED) 29 | { 30 | #if HAVE_MACH_ABSOLUTE_TIME 31 | mach_timebase_info_data_t tbi; 32 | (void)dispatch_assume_zero(mach_timebase_info(&tbi)); 33 | _dispatch_host_time_data.frac = tbi.numer; 34 | _dispatch_host_time_data.frac /= tbi.denom; 35 | _dispatch_host_time_data.ratio_1_to_1 = (tbi.numer == tbi.denom); 36 | #else // TARGET_OS_WIN32 || TARGET_OS_LINUX 37 | # if TARGET_OS_WIN32 38 | LARGE_INTEGER freq; 39 | dispatch_assume(QueryPerformanceFrequency(&freq)); 40 | _dispatch_host_time_data.win_time_factor = (long double)NSEC_PER_SEC / (long double)freq.QuadPart; 41 | # endif 42 | 43 | _dispatch_host_time_data.frac = 1.0; 44 | _dispatch_host_time_data.ratio_1_to_1 = 1; 45 | #endif 46 | } 47 | 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /libdispatch/src/shims/tsd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Apple Inc. All rights reserved. 3 | * Copyright (c) 2011-2013 MLBA-Team. All rights reserved. 4 | * 5 | * @APPLE_APACHE_LICENSE_HEADER_START@ 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * @APPLE_APACHE_LICENSE_HEADER_END@ 20 | */ 21 | 22 | #include "../internal.h" 23 | 24 | #if !HAVE_PTHREAD_KEY_INIT_NP 25 | 26 | pthread_key_t dispatch_queue_key; 27 | pthread_key_t dispatch_sema4_key; 28 | pthread_key_t dispatch_cache_key; 29 | pthread_key_t dispatch_bcounter_key; 30 | 31 | #endif 32 | 33 | int _dispatch_pthread_sigmask(int how, sigset_t *set, sigset_t *oset) 34 | { 35 | #if !TARGET_OS_WIN32 36 | int r; 37 | 38 | /* Workaround: 6269619 Not all signals can be delivered on any thread */ 39 | r = sigdelset(set, SIGILL); 40 | (void)dispatch_assume_zero(r); 41 | r = sigdelset(set, SIGTRAP); 42 | (void)dispatch_assume_zero(r); 43 | #if HAVE_DECL_SIGEMT 44 | r = sigdelset(set, SIGEMT); 45 | (void)dispatch_assume_zero(r); 46 | #endif 47 | r = sigdelset(set, SIGFPE); 48 | (void)dispatch_assume_zero(r); 49 | r = sigdelset(set, SIGBUS); 50 | (void)dispatch_assume_zero(r); 51 | r = sigdelset(set, SIGSEGV); 52 | (void)dispatch_assume_zero(r); 53 | r = sigdelset(set, SIGSYS); 54 | (void)dispatch_assume_zero(r); 55 | r = sigdelset(set, SIGPIPE); 56 | (void)dispatch_assume_zero(r); 57 | 58 | return pthread_sigmask(how, set, oset); 59 | #else 60 | return 0; 61 | #endif 62 | } 63 | -------------------------------------------------------------------------------- /libdispatch/version.rc.in: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #define VER_FILEVERSION ${XDISPATCH_DLL_VERSION} 5 | #define VER_FILEVERSION_STR "${XDISPATCH_VERSION}\0" 6 | 7 | #define VER_PRODUCTVERSION ${XDISPATCH_DLL_VERSION} 8 | #define VER_PRODUCTVERSION_STR "${XDISPATCH_VERSION}\0" 9 | 10 | #ifndef DEBUG 11 | #define VER_DEBUG 0 12 | #else 13 | #define VER_DEBUG VS_FF_DEBUG 14 | #endif 15 | 16 | VS_VERSION_INFO VERSIONINFO 17 | FILEVERSION VER_FILEVERSION 18 | PRODUCTVERSION VER_PRODUCTVERSION 19 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 20 | FILEFLAGS VS_FF_PRERELEASE 21 | FILEOS VOS__WINDOWS32 22 | FILETYPE VFT_DLL 23 | FILESUBTYPE VFT2_UNKNOWN 24 | BEGIN 25 | BLOCK "StringFileInfo" 26 | BEGIN 27 | BLOCK "040904E4" 28 | BEGIN 29 | VALUE "CompanyName", "${XDISPATCH_MAINTAINER} \251 2010-2013, Apple Inc. \251 2008-2009\0" 30 | VALUE "FileDescription", "libdispatch C Interface\0" 31 | VALUE "FileVersion", VER_FILEVERSION_STR 32 | VALUE "InternalName", "libdispatch\0" 33 | VALUE "LegalCopyright", "${XDISPATCH_MAINTAINER} \251 2010-2013, Apple Inc. \251 2008-2009\0" 34 | VALUE "OriginalFilename", "libdispatch.dll\0" 35 | VALUE "ProductName", "${XDISPATCH_SUMMARY}\0" 36 | VALUE "ProductVersion", VER_PRODUCTVERSION_STR 37 | END 38 | END 39 | END 40 | -------------------------------------------------------------------------------- /libkqueue/TODO: -------------------------------------------------------------------------------- 1 | 2 | * Create a FILTER_DECL() macro that initializes the 'struct filter' object, 3 | with all members properly initialized. Then -Wno-missing-field-initializers 4 | can be removed from CFLAGS. 5 | 6 | * Implement the knote_modify() hook for all filters. 7 | 8 | * Add a dbg_printf() statement within kevent_wait() to report the value 9 | of the timeout. 10 | 11 | * Refactor kevent_copyin() to remove the goto statements. 12 | 13 | * Fix the crasher w/ corruption in test/vnode.c 14 | 15 | * Add the kevent64() syscall as implemented on MacOS X. This guarantees 16 | that 64-bit values can be used in the 'udata' field on 32-bit platforms. 17 | 18 | * Check other filters for the EV_DISPATCH bug that was fixed in r252. 19 | 20 | * Merge the fix from r546 in the stable branch. 21 | -------------------------------------------------------------------------------- /libkqueue/config.h.in: -------------------------------------------------------------------------------- 1 | /* AUTOMATICALLY GENERATED -- DO NOT EDIT */ 2 | #cmakedefine HAVE_DECL_EPOLLRDHUP 1 3 | #cmakedefine HAVE_DECL_PPOLL 1 4 | #cmakedefine HAVE_SYS_EPOLL_H 1 5 | #cmakedefine HAVE_SYS_EVENT_H 1 6 | #cmakedefine HAVE_SYS_EVENTFD_H 1 7 | #cmakedefine HAVE_SYS_INOTIFY_H 1 8 | #cmakedefine HAVE_SYS_SIGNALFD_H 1 9 | #cmakedefine HAVE_SYS_TIMERFD_H 1 10 | -------------------------------------------------------------------------------- /libkqueue/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2011 Marius Zwicker 3 | # 4 | # Permission to use, copy, modify, and distribute this software for any 5 | # purpose with or without fee is hereby granted, provided that the above 6 | # copyright notice and this permission notice appear in all copies. 7 | # 8 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | # 16 | 17 | mz_use_default_compiler_settings() 18 | 19 | #files 20 | if(UNIX) 21 | set(SRC 22 | main.c 23 | kevent.c 24 | test.c 25 | proc.c 26 | read.c 27 | signal.c 28 | timer.c 29 | vnode.c 30 | user.c 31 | ) 32 | mz_add_c_flag(GCC 33 | -g -O0 -Wall -Werror 34 | ) 35 | else() 36 | set(SRC 37 | common.h 38 | kevent.c 39 | main.c 40 | read.c 41 | test.c 42 | timer.c 43 | user.c 44 | vnode.c 45 | ) 46 | endif() 47 | 48 | 49 | #includes 50 | include_directories( 51 | ../include 52 | ) 53 | 54 | if(UNIX) 55 | set(LIBS pthread rt) 56 | else() 57 | set(LIBS wsock32) 58 | endif() 59 | 60 | add_executable(kqueue-test ${SRC}) 61 | target_link_libraries(kqueue-test kqueue ${LIBS}) 62 | set_target_properties(kqueue-test PROPERTIES DEBUG_POSTFIX "D") 63 | -------------------------------------------------------------------------------- /libpthread_workqueue/BUGS: -------------------------------------------------------------------------------- 1 | BUGS 2 | ---- 3 | 4 | -------------------------------------------------------------------------------- /libpthread_workqueue/LICENSE: -------------------------------------------------------------------------------- 1 | /*- 2 | * Copyright (c) 2010, Mark Heily 3 | * Copyright (c) 2009, Stacey Son 4 | * Copyright (c) 2000-2008, Apple Inc. 5 | * All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice unmodified, this list of conditions, and the following 12 | * disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | * 28 | */ 29 | -------------------------------------------------------------------------------- /libpthread_workqueue/TODO: -------------------------------------------------------------------------------- 1 | * Use mmap() to store the mutex, condition variable, and counter in a 2 | process-shared mapping at $HOME/.pthread_workqueue. Mark the mutex 3 | and condition variable as process-shared. 4 | -or- 5 | Use a named semaphore at /pthread_workqueue.$UID 6 | -or- 7 | Write a kernel device driver for /dev/pthread_workqueue that will 8 | allow threads to select() for readiness to achive global load balancing. 9 | 10 | * Support Debian/kFreeBSD in the configure script. 11 | -------------------------------------------------------------------------------- /libpthread_workqueue/src/linux/thread_rt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, Joakim Johansson 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice unmodified, this list of conditions, and the following 11 | * disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | */ 28 | 29 | #include "platform.h" 30 | #include "private.h" 31 | 32 | void ptwq_set_current_thread_priority(int priority __attribute__ ((unused))) 33 | { 34 | return; 35 | } 36 | -------------------------------------------------------------------------------- /libpthread_workqueue/src/posix/platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _PTWQ_POSIX_PLATFORM_H 2 | #define _PTWQ_POSIX_PLATFORM_H 1 3 | 4 | /* Workaround to get visibility for _SC_NPROCESSORS_ONLN on FreeBSD */ 5 | #define __BSD_VISIBLE 1 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #ifdef __sun 16 | # include 17 | #endif 18 | 19 | /* GCC atomic builtins. 20 | * See: http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc/Atomic-Builtins.html 21 | */ 22 | #ifdef __sun 23 | # include 24 | # define atomic_inc atomic_inc_32 25 | # define atomic_dec atomic_dec_32 26 | # define atomic_inc_nv atomic_inc_32_nv 27 | # define atomic_dec_nv atomic_dec_32_nv 28 | # define atomic_and atomic_and_uint_nv 29 | # define atomic_or atomic_or_uint_nv 30 | #else 31 | # define atomic_inc(p) (void) __sync_add_and_fetch((p), 1) 32 | # define atomic_dec(p) (void) __sync_sub_and_fetch((p), 1) 33 | # define atomic_inc_nv(p) __sync_add_and_fetch((p), 1) 34 | # define atomic_dec_nv(p) __sync_sub_and_fetch((p), 1) 35 | # define atomic_and(p,v) __sync_and_and_fetch((p), (v)) 36 | # define atomic_or(p,v) __sync_or_and_fetch((p), (v)) 37 | #endif 38 | 39 | #ifdef MAKE_STATIC 40 | # define CONSTRUCTOR 41 | #else 42 | # define CONSTRUCTOR __attribute__ ((constructor)) 43 | #endif 44 | #define VISIBLE __attribute__((visibility("default"))) 45 | 46 | /* 47 | * Android does not provide spinlocks. 48 | * See: http://code.google.com/p/android/issues/detail?id=21622 49 | */ 50 | #if defined(__ANDROID__) 51 | #define pthread_spinlock_t pthread_mutex_t 52 | #define pthread_spin_lock pthread_mutex_lock 53 | #define pthread_spin_unlock pthread_mutex_unlock 54 | #define pthread_spin_init(a,b) pthread_mutex_init((a), NULL) 55 | #define pthread_spin_destroy pthread_mutex_destroy 56 | #endif /* defined(__ANDROID__) */ 57 | 58 | #endif /* _PTWQ_POSIX_PLATFORM_H */ 59 | -------------------------------------------------------------------------------- /libpthread_workqueue/src/posix/thread_info.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, Joakim Johansson 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice unmodified, this list of conditions, and the following 11 | * disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | */ 28 | 29 | // Default POSIX implementation doesn't support it, platform-specific code does though. 30 | 31 | #if !(defined(__linux__) || defined(__sun)) 32 | 33 | int threads_runnable(unsigned int *threads_running, unsigned int *threads_total) 34 | { 35 | return -1; 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /libpthread_workqueue/src/posix/thread_rt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, Joakim Johansson 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice unmodified, this list of conditions, and the following 11 | * disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | */ 28 | 29 | // Default POSIX implementation doesn't support it, platform-specific code does though. 30 | 31 | #if !(defined(__linux__) || defined(__sun)) 32 | 33 | void ptwq_set_current_thread_priority(int priority) 34 | { 35 | return; 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /libpthread_workqueue/src/solaris/platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012, Joakim Johansson 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice unmodified, this list of conditions, and the following 10 | * disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 15 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | * 26 | */ 27 | 28 | #ifndef _LIBPWQ_SOLARIS_PLATFORM_H 29 | #define _LIBPWQ_SOLARIS_PLATFORM_H 30 | 31 | /* 32 | * Platform-specific functions for Solaris 33 | */ 34 | 35 | unsigned int solaris_get_runqueue_length(void); 36 | 37 | #endif /* _LIBPWQ_SOLARIS_PLATFORM_H */ 38 | -------------------------------------------------------------------------------- /libpthread_workqueue/src/thread_info.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, Joakim Johansson 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice unmodified, this list of conditions, and the following 11 | * disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | */ 28 | 29 | #ifndef _PTWQ_POSIX_THREAD_INFO_H 30 | #define _PTWQ_POSIX_THREAD_INFO_H 1 31 | 32 | int threads_runnable(unsigned int *threads_running, unsigned int *threads_total); 33 | 34 | #endif /* _PTWQ_POSIX_THREAD_INFO_H */ 35 | -------------------------------------------------------------------------------- /libpthread_workqueue/src/thread_rt.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, Joakim Johansson 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice unmodified, this list of conditions, and the following 11 | * disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | */ 28 | 29 | #ifndef _PTWQ_THREAD_RT_H 30 | #define _PTWQ_THREAD_RT_H 1 31 | 32 | void ptwq_set_current_thread_priority(int priority); // higher is better 33 | 34 | #endif /* _PTWQ_THREAD_RT_H */ 35 | -------------------------------------------------------------------------------- /libpthread_workqueue/src/windows/platform.h: -------------------------------------------------------------------------------- 1 | #ifndef _PTWQ_WINDOWS_PLATFORM_H 2 | #define _PTWQ_WINDOWS_PLATFORM_H 1 3 | 4 | #define PROVIDE_LEGACY_XP_SUPPORT 1 5 | #define _CRT_SECURE_NO_WARNINGS 6 | 7 | #ifndef __GNUC__ 8 | # pragma warning(disable : 4996) 9 | #endif 10 | 11 | #ifdef PROVIDE_LEGACY_XP_SUPPORT 12 | # define _WIN32_WINNT 0x0500 13 | #else 14 | # define _WIN32_WINNT 0x0610 15 | #endif 16 | #define WIN32_LEAN_AND_MEAN 17 | 18 | #ifndef __MSVCRT_VERSION__ 19 | # define __MSVCRT_VERSION__ 0x0601 20 | #endif 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | /* Instead of __attribute__ ((constructor)), use DllMain() */ 30 | #define CONSTRUCTOR /* */ 31 | 32 | #define VISIBLE __declspec(dllexport) 33 | 34 | # define __func__ __FUNCTION__ 35 | # define inline __inline 36 | # define bool BOOL 37 | 38 | #undef LIST_HEAD 39 | #include "queue.h" 40 | 41 | #define sleep(sec) Sleep(1000*sec) 42 | #define strdup(p) _strdup(p) 43 | #define random() rand() 44 | 45 | // some constants used throughout the code 46 | #ifndef ENOTSUP 47 | # define ENOTSUP 300 48 | #endif 49 | #ifndef ETIMEDOUT 50 | # define ETIMEDOUT WSAETIMEDOUT 51 | #endif 52 | #ifndef PATH_MAX 53 | # define PATH_MAX 512 54 | #endif 55 | 56 | #include "times.h" 57 | #include "threads.h" 58 | 59 | #ifdef PROVIDE_LEGACY_XP_SUPPORT 60 | # define WORKQUEUE_PLATFORM_SPECIFIC \ 61 | LIST_ENTRY(_pthread_workqueue) wqlist_entry 62 | #else 63 | /* Specific workqueue items */ 64 | # define WORKQUEUE_PLATFORM_SPECIFIC \ 65 | PTP_POOL win_thread_pool; \ 66 | TP_CALLBACK_ENVIRON win_callback_env 67 | #endif 68 | 69 | #endif /* _PTWQ_WINDOWS_PLATFORM_H */ 70 | -------------------------------------------------------------------------------- /libpthread_workqueue/src/windows/posix_semaphore.h: -------------------------------------------------------------------------------- 1 | #ifndef DISPATCH_WIN_POSIX_SEMAPHORE_ 2 | #define DISPATCH_WIN_POSIX_SEMAPHORE_ 3 | 4 | typedef HANDLE sem_t; 5 | 6 | static int sem_init(sem_t * sem, int shared, unsigned int val) 7 | { 8 | *sem = CreateSemaphore(0, val, 1, 0); 9 | // TODO: Proper error handling 10 | return *sem == 0; 11 | } 12 | 13 | static inline int sem_destroy(sem_t* s) 14 | { 15 | return CloseHandle(s) != 1; 16 | } 17 | 18 | static inline int sem_post(sem_t* s) 19 | { 20 | return !ReleaseSemaphore(s, 1, 0); 21 | } 22 | 23 | static inline int sem_wait(sem_t* s) 24 | { 25 | return WaitForSingleObject(s, INFINITE) == WAIT_FAILED; 26 | } 27 | 28 | static int sem_timedwait(sem_t * sem, const struct timespec * timeout) 29 | { 30 | DWORD duration = (DWORD)(timeout->tv_nsec / 1000000) + (DWORD)(timeout->tv_sec * 1000); 31 | 32 | switch(WaitForSingleObject(sem,duration) ){ 33 | case WAIT_TIMEOUT: 34 | return ETIMEDOUT; 35 | case WAIT_FAILED: 36 | return EINVAL; 37 | default: 38 | return 0; 39 | } 40 | } 41 | 42 | #endif /* DISPATCH_WIN_POSIX_SEMAPHORE_ */ 43 | -------------------------------------------------------------------------------- /libpthread_workqueue/src/windows/thread_info.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, Joakim Johansson 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice unmodified, this list of conditions, and the following 11 | * disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | */ 28 | 29 | int threads_runnable(unsigned int *threads_running, unsigned int *threads_total) 30 | { 31 | return -1; 32 | } 33 | -------------------------------------------------------------------------------- /libpthread_workqueue/src/windows/thread_rt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011, Joakim Johansson 3 | * 4 | * All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice unmodified, this list of conditions, and the following 11 | * disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | */ 28 | 29 | void ptwq_set_current_thread_priority(int priority) 30 | { 31 | return; 32 | } 33 | -------------------------------------------------------------------------------- /libpthread_workqueue/src/windows/threads.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010 Apple Inc. All rights reserved. 3 | * Copyright (c) 2011 MLBA. All rights reserved. 4 | * Copyright (c) 2010 Mark Heily 5 | * 6 | * @APPLE_APACHE_LICENSE_HEADER_START@ 7 | * 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | * @APPLE_APACHE_LICENSE_HEADER_END@ 21 | */ 22 | 23 | #ifndef THREADS_WIN_H_ 24 | #define THREADS_WIN_H_ 25 | 26 | /* 27 | Needs to be set to ensure we are using only function calls 28 | availabe on windows XP and later. (Windows Vista when not set) 29 | */ 30 | #define TARGET_OS_WIN_XP PROVIDE_LEGACY_XP_SUPPORT 31 | 32 | #include "pthread_mutex.h" 33 | #include "pthread_create.h" 34 | #include "pthread_cond_variables.h" 35 | #include "pthread_tls.h" 36 | #include "pthread_rw_lock.h" 37 | #include "posix_semaphore.h" 38 | 39 | /* signals */ 40 | typedef int sigset_t; 41 | 42 | #endif /* THREADS_WIN_H_ */ 43 | -------------------------------------------------------------------------------- /libpthread_workqueue/testing/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2011 Marius Zwicker 3 | # 4 | # Permission to use, copy, modify, and distribute this software for any 5 | # purpose with or without fee is hereby granted, provided that the above 6 | # copyright notice and this permission notice appear in all copies. 7 | # 8 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | # 16 | 17 | #files 18 | set(API api/test.c) 19 | set(WITEM_CACHE witem_cache/test.c) 20 | set(LATENCY latency/latency.c latency/latency.h) 21 | 22 | 23 | #includes 24 | include_directories( 25 | ../include 26 | ) 27 | 28 | if(UNIX) 29 | add_definitions( 30 | -DNO_CONFIG_H 31 | ) 32 | endif() 33 | 34 | add_executable(test_api_pthread_workqueue ${API}) 35 | target_link_libraries(test_api_pthread_workqueue pthread_workqueue) 36 | set_target_properties(test_api_pthread_workqueue PROPERTIES DEBUG_POSTFIX "D") 37 | 38 | add_executable(test_latency_pthread_workqueue ${LATENCY}) 39 | target_link_libraries(test_latency_pthread_workqueue pthread_workqueue) 40 | 41 | if(NOT WIN32) 42 | 43 | #add_executable(test_witem_cache_pthread_workqueue ${WITEM_CACHE}) 44 | #target_link_libraries(test_witem_cache_pthread_workqueue pthreads_workqueue) 45 | 46 | endif() 47 | -------------------------------------------------------------------------------- /libpthread_workqueue/testing/api/posix_semaphore.h: -------------------------------------------------------------------------------- 1 | #ifndef DISPATCH_WIN_POSIX_SEMAPHORE_ 2 | #define DISPATCH_WIN_POSIX_SEMAPHORE_ 3 | 4 | typedef HANDLE sem_t; 5 | 6 | static int sem_init(sem_t * sem, int shared, unsigned int val) 7 | { 8 | *sem = CreateSemaphore(0, val, 1, 0); 9 | // TODO: Proper error handling 10 | return *sem == 0; 11 | } 12 | 13 | static inline int sem_destroy(sem_t* s) 14 | { 15 | return CloseHandle(s) != 1; 16 | } 17 | 18 | static inline int sem_post(sem_t* s) 19 | { 20 | return !ReleaseSemaphore(s, 1, 0); 21 | } 22 | 23 | static inline int sem_wait(sem_t* s) 24 | { 25 | return WaitForSingleObject(s, INFINITE) == WAIT_FAILED; 26 | } 27 | 28 | static int sem_timedwait(sem_t * sem, const struct timespec * timeout) 29 | { 30 | DWORD duration = (DWORD)(timeout->tv_nsec / 1000000) + (DWORD)(timeout->tv_sec * 1000); 31 | 32 | switch(WaitForSingleObject(sem,duration) ){ 33 | case WAIT_TIMEOUT: 34 | return ETIMEDOUT; 35 | case WAIT_FAILED: 36 | return EINVAL; 37 | default: 38 | return 0; 39 | } 40 | } 41 | 42 | #endif /* DISPATCH_WIN_POSIX_SEMAPHORE_ */ 43 | -------------------------------------------------------------------------------- /libpthread_workqueue/testing/libdispatch/Makefile: -------------------------------------------------------------------------------- 1 | CC=clang 2 | 3 | dispatch_api: 4 | $(CC) -o dispatch_api dispatch_api.c -lpthread -lrt -ldispatch -lBlocksRuntime -lkqueue -lpthread_workqueue 5 | 6 | check: dispatch_api 7 | ./dispatch_api 8 | 9 | clean: 10 | rm -f dispatch_api 11 | -------------------------------------------------------------------------------- /libpthread_workqueue/testing/libdispatch/dispatch_api.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011 Mark Heily. 3 | * Copyright (c) 2008-2009 Apple Inc. All rights reserved. 4 | * 5 | * @APPLE_APACHE_LICENSE_HEADER_START@ 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * @APPLE_APACHE_LICENSE_HEADER_END@ 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | void 29 | work(void *context __attribute__((unused))) 30 | { 31 | puts("work complete"); 32 | exit(0); 33 | } 34 | 35 | int main(void) { 36 | dispatch_queue_t q = dispatch_get_main_queue(); 37 | dispatch_sync_f(dispatch_get_main_queue(), NULL, work); 38 | dispatch_main(); 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /libqtdispatch/include/QtDispatch/QBlockRunnable: -------------------------------------------------------------------------------- 1 | #include "qblockrunnable.h" -------------------------------------------------------------------------------- /libqtdispatch/include/QtDispatch/QDispatch: -------------------------------------------------------------------------------- 1 | #include "qdispatch.h" -------------------------------------------------------------------------------- /libqtdispatch/include/QtDispatch/QDispatchApplication: -------------------------------------------------------------------------------- 1 | #include "qdispatchapplication.h" 2 | -------------------------------------------------------------------------------- /libqtdispatch/include/QtDispatch/QDispatchCoreApplication: -------------------------------------------------------------------------------- 1 | #include "qdispatchcoreapplication.h" 2 | -------------------------------------------------------------------------------- /libqtdispatch/include/QtDispatch/QDispatchGroup: -------------------------------------------------------------------------------- 1 | #include "qdispatchgroup.h" -------------------------------------------------------------------------------- /libqtdispatch/include/QtDispatch/QDispatchQueue: -------------------------------------------------------------------------------- 1 | #include "qdispatchqueue.h" -------------------------------------------------------------------------------- /libqtdispatch/include/QtDispatch/QDispatchSemaphore: -------------------------------------------------------------------------------- 1 | #include "qdispatchsemaphore.h" -------------------------------------------------------------------------------- /libqtdispatch/include/QtDispatch/QDispatchSource: -------------------------------------------------------------------------------- 1 | #include "qdispatchsource.h" -------------------------------------------------------------------------------- /libqtdispatch/include/QtDispatch/QDispatchTimer: -------------------------------------------------------------------------------- 1 | #include "qdispatchtimer.h" 2 | -------------------------------------------------------------------------------- /libqtdispatch/include/QtDispatch/QIterationBlockRunnable: -------------------------------------------------------------------------------- 1 | #include "qiterationblockrunnable.h" 2 | -------------------------------------------------------------------------------- /libqtdispatch/include/QtDispatch/QIterationRunnable: -------------------------------------------------------------------------------- 1 | #include "qiterationrunnable.h" 2 | -------------------------------------------------------------------------------- /libqtdispatch/include/QtDispatch/QtDispatch: -------------------------------------------------------------------------------- 1 | #ifndef QT_DISPATCH_H_ 2 | #define QT_DISPATCH_H_ 3 | 4 | #include "qblockrunnable.h" 5 | #include "qiterationblockrunnable.h" 6 | #include "qdispatch.h" 7 | #include "qdispatchgroup.h" 8 | #include "qdispatchqueue.h" 9 | #include "qdispatchsemaphore.h" 10 | #include "qdispatchcoreapplication.h" 11 | #include "qdispatchapplication.h" 12 | #include "qdispatchtimer.h" 13 | #include "qdispatchsource.h" 14 | 15 | #endif /* QT_DISPATCH_H_ */ -------------------------------------------------------------------------------- /libqtdispatch/include/QtDispatch/qdispatchapplication.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qdispatchapplication.h 3 | * 4 | * Copyright (c) 2011-2018 MLBA-Team 5 | * All rights reserved. 6 | * 7 | * @LICENSE_HEADER_START@ 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * @LICENSE_HEADER_END@ 20 | */ 21 | 22 | 23 | #ifndef QDISPATCH_APPLICATION_H_ 24 | #define QDISPATCH_APPLICATION_H_ 25 | 26 | #include 27 | #include "qdispatchglobal.h" 28 | 29 | /** 30 | * @addtogroup qtdispatch 31 | * @{ 32 | */ 33 | 34 | QT_BEGIN_HEADER 35 | QT_BEGIN_NAMESPACE QT_MODULE( 36 | Dispatch 37 | ) 38 | 39 | /** 40 | Provides a QApplication implementation internally executing 41 | the dispatch main queue. When used you can dispatch work onto the 42 | main thread by dispatching to the main_queue obtained by calling 43 | QDispatch::mainQueue(). 44 | */ 45 | class Q_DISPATCH_EXPORT QDispatchApplication 46 | : public QApplication 47 | { 48 | Q_OBJECT 49 | 50 | 51 | public: 52 | QDispatchApplication( 53 | int& argc, 54 | char** argv 55 | ); 56 | ~QDispatchApplication(); 57 | 58 | 59 | private: 60 | Q_DISABLE_COPY( QDispatchApplication ) 61 | }; 62 | 63 | 64 | QT_END_NAMESPACE 65 | QT_END_HEADER 66 | 67 | /** @} */ 68 | 69 | #endif /* QDISPATCH_APPLICATION_H_ */ -------------------------------------------------------------------------------- /libqtdispatch/include/QtDispatch/qdispatchglobal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qdispatchglobal.h 3 | * 4 | * Copyright (c) 2011-2018 MLBA-Team 5 | * All rights reserved. 6 | * 7 | * @LICENSE_HEADER_START@ 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * @LICENSE_HEADER_END@ 20 | */ 21 | 22 | 23 | #ifndef QDISPATCH_GLOBAL_H_ 24 | #define QDISPATCH_GLOBAL_H_ 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | /** 33 | * @addtogroup qtdispatch 34 | * @{ 35 | */ 36 | 37 | #ifndef QT_MODULE 38 | #define QT_MODULE( X ) 39 | #define QT_LICENSED_MODULE( X ) 40 | #define QT_BEGIN_NAMESPACE 41 | #define QT_END_NAMESPACE 42 | #define QT_BEGIN_HEADER 43 | #define QT_END_HEADER 44 | #endif // ifndef QT_MODULE 45 | 46 | #if defined ( QT_MAKEDLL ) || !defined ( _WIN32 ) 47 | #define Q_DISPATCH_EXPORT Q_DECL_EXPORT 48 | #else 49 | #define Q_DISPATCH_EXPORT Q_DECL_IMPORT 50 | #endif 51 | 52 | #ifdef QT_LICENSED_MODULE 53 | QT_LICENSED_MODULE( Dispatch ) 54 | #endif 55 | 56 | QT_BEGIN_HEADER 57 | QT_BEGIN_NAMESPACE QT_MODULE( 58 | Dispatch 59 | ) 60 | 61 | QT_END_NAMESPACE 62 | QT_END_HEADER 63 | 64 | /** @} */ 65 | 66 | #endif /* QDISPATCH_GLOBAL_H_ */ -------------------------------------------------------------------------------- /libqtdispatch/include/QtDispatch/qiterationrunnable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * qiterationrunnable.h 3 | * 4 | * Copyright (c) 2011-2018 MLBA-Team 5 | * All rights reserved. 6 | * 7 | * @LICENSE_HEADER_START@ 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * @LICENSE_HEADER_END@ 20 | */ 21 | 22 | 23 | #ifndef QITERATIONRUNNABLE_H_ 24 | #define QITERATIONRUNNABLE_H_ 25 | 26 | #include "qdispatchglobal.h" 27 | 28 | #include 29 | 30 | /** 31 | * @addtogroup qtdispatch 32 | * @{ 33 | */ 34 | 35 | QT_BEGIN_HEADER 36 | QT_BEGIN_NAMESPACE QT_MODULE( 37 | Dispatch 38 | ) 39 | 40 | /** 41 | Provides a QRunnable Implementation for passing 42 | a single parameter to the actual run() implementation. 43 | 44 | This can for example be used in a case when for each iteration 45 | of a loop a new QRunnable will be created and you want to know 46 | during the execution of each runnable at which iteration it 47 | was created. 48 | */ 49 | class Q_DISPATCH_EXPORT QIterationRunnable 50 | : public QRunnable 51 | { 52 | public: 53 | /** 54 | Constructs a new QBlockRunnable passing 55 | the given parameter. 56 | */ 57 | QIterationRunnable() 58 | : QRunnable() { } 59 | 60 | 61 | QIterationRunnable( 62 | const QIterationRunnable& o 63 | ) 64 | : QRunnable( o ) { } 65 | 66 | 67 | virtual void run( 68 | size_t index 69 | ) = 0; 70 | 71 | 72 | private: 73 | virtual void run() { } 74 | }; 75 | 76 | 77 | QT_END_NAMESPACE 78 | QT_END_HEADER 79 | 80 | /** @} */ 81 | 82 | #endif /* QITERATIONRUNNABLE_H_ */ -------------------------------------------------------------------------------- /libqtdispatch/src/qdispatchapplication.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * qdispatchapplication.cpp 3 | * 4 | * Copyright (c) 2011-2018 MLBA-Team 5 | * All rights reserved. 6 | * 7 | * @LICENSE_HEADER_START@ 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * @LICENSE_HEADER_END@ 20 | */ 21 | 22 | 23 | #include 24 | 25 | #include "../include/QtDispatch/qdispatchapplication.h" 26 | 27 | #ifndef Q_OS_MAC 28 | 29 | # include "qdispatchapplicationprivate.h" 30 | 31 | QT_BEGIN_NAMESPACE 32 | 33 | QDispatchApplication::QDispatchApplication( 34 | int& argc, 35 | char** argv 36 | ) 37 | : QApplication( argc, argv ) 38 | { 39 | QDispatchLibBridge::registerCallback(); 40 | } 41 | 42 | 43 | QDispatchApplication::~QDispatchApplication() 44 | { 45 | QDispatchLibBridge::removeCallback(); 46 | } 47 | 48 | 49 | QT_END_NAMESPACE 50 | 51 | #endif // ifndef Q_OS_MAC -------------------------------------------------------------------------------- /libqtdispatch/src/qdispatchapplication_mac.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * qdispatchapplication_mac.cpp 3 | * 4 | * Copyright (c) 2011-2018 MLBA-Team 5 | * All rights reserved. 6 | * 7 | * @LICENSE_HEADER_START@ 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * @LICENSE_HEADER_END@ 20 | */ 21 | 22 | 23 | #include 24 | 25 | #include "../include/QtDispatch/qdispatchapplication.h" 26 | 27 | #ifdef Q_OS_MAC 28 | 29 | #if !defined ( QT_MAC_USE_COCOA ) && !defined ( Q_OS_MAC /* Qt 5+ only */ ) 30 | # error "QtDispatch is supporting Qt built on Cocoa only" 31 | #endif 32 | 33 | QT_BEGIN_NAMESPACE 34 | 35 | QDispatchApplication::QDispatchApplication( 36 | int& argc, 37 | char** argv 38 | ) 39 | : QApplication( argc, argv ) { } 40 | 41 | 42 | QDispatchApplication::~QDispatchApplication() { } 43 | 44 | 45 | QT_END_NAMESPACE 46 | 47 | #endif // ifdef Q_OS_MAC -------------------------------------------------------------------------------- /libqtdispatch/src/qdispatchcoreapplication.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * qdispatchcoreapplication.cpp 3 | * 4 | * Copyright (c) 2011-2018 MLBA-Team 5 | * All rights reserved. 6 | * 7 | * @LICENSE_HEADER_START@ 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * @LICENSE_HEADER_END@ 20 | */ 21 | 22 | 23 | #include 24 | #include 25 | 26 | #include "../include/QtDispatch/qdispatchcoreapplication.h" 27 | 28 | #ifndef Q_OS_MAC 29 | 30 | # include "qdispatchapplicationprivate.h" 31 | 32 | QT_BEGIN_NAMESPACE 33 | 34 | QEvent::Type QDispatchEvent::TYPECONSTANT; 35 | QDispatchLibBridge* QDispatchLibBridge::instance; 36 | 37 | QDispatchCoreApplication::QDispatchCoreApplication( 38 | int& argc, 39 | char** argv 40 | ) 41 | : QCoreApplication( argc, argv ) 42 | { 43 | QDispatchLibBridge::registerCallback(); 44 | } 45 | 46 | 47 | QDispatchCoreApplication::~QDispatchCoreApplication() 48 | { 49 | QDispatchLibBridge::removeCallback(); 50 | } 51 | 52 | 53 | QT_END_NAMESPACE 54 | 55 | #endif /* Q_OS_MAC */ -------------------------------------------------------------------------------- /libqtdispatch/src/qdispatchcoreapplication_mac.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * qdispatchcoreapplication_mac.cpp 3 | * 4 | * Copyright (c) 2011-2018 MLBA-Team 5 | * All rights reserved. 6 | * 7 | * @LICENSE_HEADER_START@ 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * @LICENSE_HEADER_END@ 20 | */ 21 | 22 | 23 | #include 24 | #include 25 | 26 | #include "../include/QtDispatch/qdispatchcoreapplication.h" 27 | 28 | #ifdef Q_OS_MAC 29 | 30 | QT_BEGIN_NAMESPACE 31 | 32 | 33 | QDispatchCoreApplication::QDispatchCoreApplication( 34 | int& argc, 35 | char** argv 36 | ) 37 | : QDispatchApplication( argc, argv ) 38 | { 39 | qCritical( "QDispatchCoreApplication is implemented as QApplication on this platform. We recommend to use QDispatchApplication instead." ); 40 | } 41 | 42 | 43 | QT_END_NAMESPACE 44 | 45 | #endif /* Q_OS_MAC */ -------------------------------------------------------------------------------- /libqtdispatch/src/qrunnableoperations.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * qrunnableoperations.cpp 3 | * 4 | * Copyright (c) 2011-2018 MLBA-Team 5 | * All rights reserved. 6 | * 7 | * @LICENSE_HEADER_START@ 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * @LICENSE_HEADER_END@ 20 | */ 21 | 22 | 23 | #include "qrunnableoperations.h" 24 | #include "../include/QtDispatch/qblockrunnable.h" 25 | #include "../include/QtDispatch/qiterationblockrunnable.h" 26 | 27 | 28 | xdispatch::iteration_operation* xdispatch::make_iteration_operation( 29 | QIterationRunnable* runnable 30 | ) 31 | { 32 | return new IterationRunnableOperation( runnable ); 33 | } 34 | 35 | xdispatch::operation* xdispatch::make_operation( 36 | QRunnable* runnable 37 | ) 38 | { 39 | return new RunnableOperation( runnable ); 40 | } 41 | -------------------------------------------------------------------------------- /libqtdispatch/version.rc.in: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #define VER_FILEVERSION ${XDISPATCH_DLL_VERSION} 5 | #define VER_FILEVERSION_STR "${XDISPATCH_VERSION}\0" 6 | 7 | #define VER_PRODUCTVERSION ${XDISPATCH_DLL_VERSION} 8 | #define VER_PRODUCTVERSION_STR "${XDISPATCH_VERSION}\0" 9 | 10 | #ifndef DEBUG 11 | #define VER_DEBUG 0 12 | #else 13 | #define VER_DEBUG VS_FF_DEBUG 14 | #endif 15 | 16 | VS_VERSION_INFO VERSIONINFO 17 | FILEVERSION VER_FILEVERSION 18 | PRODUCTVERSION VER_PRODUCTVERSION 19 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 20 | FILEFLAGS VS_FF_PRERELEASE 21 | FILEOS VOS__WINDOWS32 22 | FILETYPE VFT_DLL 23 | FILESUBTYPE VFT2_UNKNOWN 24 | BEGIN 25 | BLOCK "StringFileInfo" 26 | BEGIN 27 | BLOCK "040904E4" 28 | BEGIN 29 | VALUE "CompanyName", "${XDISPATCH_MAINTAINER} \251 2010-2013\0" 30 | VALUE "FileDescription", "libQtDispatch Qt Compatibility Layer\0" 31 | VALUE "FileVersion", VER_FILEVERSION_STR 32 | VALUE "InternalName", "libQtDispatch\0" 33 | VALUE "LegalCopyright", "${XDISPATCH_MAINTAINER} \251 2010-2013\0" 34 | VALUE "OriginalFilename", "libQtDispatch.dll\0" 35 | VALUE "ProductName", "${XDISPATCH_SUMMARY}\0" 36 | VALUE "ProductVersion", VER_PRODUCTVERSION_STR 37 | END 38 | END 39 | END 40 | -------------------------------------------------------------------------------- /libxdispatch/include/xdispatch/dispatch: -------------------------------------------------------------------------------- 1 | #include "dispatch.h" -------------------------------------------------------------------------------- /libxdispatch/include/xdispatch/dispatch_decl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * dispatch_decl.h 3 | * 4 | * Copyright (c) 2011-2018 MLBA-Team 5 | * All rights reserved. 6 | * 7 | * @LICENSE_HEADER_START@ 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * @LICENSE_HEADER_END@ 20 | */ 21 | 22 | 23 | #ifndef XDISPATCH_DECL_H_ 24 | #define XDISPATCH_DECL_H_ 25 | 26 | #include "platform.h" 27 | 28 | #if XDISPATCH_COMPILER_MSVC2017 || XDISPATCH_COMPILER_MSVC2010 || XDISPATCH_COMPILER_MSVC2008SP1 29 | #pragma warning(disable: 4251) /* disable warning C4251 - * requires dll-interface */ 30 | #ifdef XDISPATCH_MAKEDLL 31 | #define XDISPATCH_EXPORT __declspec( dllexport ) 32 | #else 33 | #define XDISPATCH_EXPORT __declspec( dllimport ) 34 | #endif 35 | #define XDISPATCH_DEPRECATED( F ) __declspec( deprecated ) F 36 | #elif XDISPATCH_COMPILER_GCC || XDISPATCH_COMPILER_CLANG 37 | #define XDISPATCH_EXPORT __attribute__( ( __visibility__( "default" ) ) ) 38 | #define XDISPATCH_DEPRECATED( F ) __attribute__ ( ( __deprecated__ ) ) F 39 | #endif // if XDISPATCH_COMPILER_MSVC2010 || XDISPATCH_COMPILER_MSVC2008SP1 40 | 41 | 42 | #define __XDISPATCH_BEGIN_NAMESPACE \ 43 | namespace xdispatch \ 44 | { 45 | #define __XDISPATCH_END_NAMESPACE \ 46 | } 47 | 48 | 49 | /* 50 | #ifdef _WIN32 51 | # pragma warning(default: 4251) // re-enable warning C4251 - we do not want to influence other code 52 | #endif 53 | */ 54 | 55 | 56 | #endif /* XDISPATCH_DECL_H_ */ -------------------------------------------------------------------------------- /libxdispatch/src/execution.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2013 MLBA-Team. All rights reserved. 3 | * 4 | * @MLBA_OPEN_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 | * @MLBA_OPEN_LICENSE_HEADER_END@ 19 | */ 20 | 21 | #ifndef XDISPATCH_INT_EXECUTION_H_ 22 | #define XDISPATCH_INT_EXECUTION_H_ 23 | 24 | extern "C" { 25 | XDISPATCH_EXPORT void 26 | _xdispatch_run_operation( 27 | void* 28 | ); 29 | 30 | XDISPATCH_EXPORT void _xdispatch_run_iter_wrap( void*, size_t ); 31 | } 32 | 33 | __XDISPATCH_BEGIN_NAMESPACE 34 | 35 | 36 | class XDISPATCH_EXPORT iteration_wrap 37 | { 38 | public: 39 | iteration_wrap( 40 | iteration_operation* o, 41 | size_t ct 42 | ); 43 | ~iteration_wrap(); 44 | iteration_operation* operation(); 45 | 46 | bool deref(); 47 | 48 | 49 | private: 50 | iteration_operation* op; 51 | uintptr_t ref; 52 | }; 53 | 54 | 55 | __XDISPATCH_END_NAMESPACE 56 | 57 | #endif /* XDISPATCH_INT_EXECUTION_H_ */ -------------------------------------------------------------------------------- /libxdispatch/version.rc.in: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #define VER_FILEVERSION ${XDISPATCH_DLL_VERSION} 5 | #define VER_FILEVERSION_STR "${XDISPATCH_VERSION}\0" 6 | 7 | #define VER_PRODUCTVERSION ${XDISPATCH_DLL_VERSION} 8 | #define VER_PRODUCTVERSION_STR "${XDISPATCH_VERSION}\0" 9 | 10 | #ifndef DEBUG 11 | #define VER_DEBUG 0 12 | #else 13 | #define VER_DEBUG VS_FF_DEBUG 14 | #endif 15 | 16 | VS_VERSION_INFO VERSIONINFO 17 | FILEVERSION VER_FILEVERSION 18 | PRODUCTVERSION VER_PRODUCTVERSION 19 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 20 | FILEFLAGS VS_FF_PRERELEASE 21 | FILEOS VOS__WINDOWS32 22 | FILETYPE VFT_DLL 23 | FILESUBTYPE VFT2_UNKNOWN 24 | BEGIN 25 | BLOCK "StringFileInfo" 26 | BEGIN 27 | BLOCK "040904E4" 28 | BEGIN 29 | VALUE "CompanyName", "${XDISPATCH_MAINTAINER} \251 2010-2013\0" 30 | VALUE "FileDescription", "libxdispatch C++ Interface\0" 31 | VALUE "FileVersion", VER_FILEVERSION_STR 32 | VALUE "InternalName", "libxdispatch\0" 33 | VALUE "LegalCopyright", "${XDISPATCH_MAINTAINER} \251 2010-2013\0" 34 | VALUE "OriginalFilename", "libxdispatch.dll\0" 35 | VALUE "ProductName", "${XDISPATCH_SUMMARY}\0" 36 | VALUE "ProductVersion", VER_PRODUCTVERSION_STR 37 | END 38 | END 39 | END 40 | -------------------------------------------------------------------------------- /package/debian/README.Debian: -------------------------------------------------------------------------------- 1 | Notes for the Debian xdispatch packages: 2 | 3 | To compile code against libdispatch, use: 4 | 5 | gcc -c code.c -o code.o -ldispatch 6 | 7 | To compile code against libxdispatch, use: 8 | 9 | g++ -c code.cpp -o code.o -lxdispatch -ldispatch 10 | 11 | -------------------------------------------------------------------------------- /package/debian/README.source: -------------------------------------------------------------------------------- 1 | README.source 2 | 3 | The source package uses quilt to manage all modifications to the upstream 4 | source. Changes are stored in the source package as diffs in debian/patches 5 | and applied during the build. 6 | 7 | See /usr/share/doc/quilt/README.source for a detailed explanation. 8 | 9 | -------------------------------------------------------------------------------- /package/debian/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /package/debian/deb.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # deb.cmake 3 | # 4 | # Copyright (c) 2011-2014 MLBA-Team 5 | # All rights reserved. 6 | # 7 | # @LICENSE_HEADER_START@ 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # @LICENSE_HEADER_END@ 20 | # 21 | 22 | set( CPACK_DEBIAN_PACKAGE_NAME "libxdispatch") 23 | set( CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>=2.13-1) , libgcc1 (>=4.5.1), libstdc++6 (>=4.5.1)") 24 | set( CPACK_DEBIAN_PACKAGE_MAINTAINER "${XDISPATCH_MAINTAINER}") 25 | set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "${XDISPATCH_SUMMARY}") 26 | set( CPACK_PACKAGE_DESCRIPTION "${XDISPATCH_DESCRIPTION}") 27 | set( CPACK_DEBIAN_PACKAGE_SECTION "Devel") 28 | set( CPACK_DEBIAN_PACKAGE_VERSION "${XDISPATCH_VERSION}-${PACKAGE_COMPILER}") 29 | set( CPACK_DEBIAN_COMPONENT_INSTALL ON) # enable me as soon as component based deb files work with cmake 30 | 31 | add_custom_target( 32 | debian ./package/debian/package.sh xdispatch-${XDISPATCH_VERSION} 33 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 34 | ) 35 | 36 | configure_file( 37 | ${CMAKE_CURRENT_SOURCE_DIR}/package/debian/changelog.in 38 | ${CMAKE_CURRENT_SOURCE_DIR}/package/debian/changelog 39 | ) 40 | 41 | message("-- Configured generator 'DEB (Debian)'") 42 | set( XDISPATCH_CPACK ${XDISPATCH_CPACK} DEB ) 43 | -------------------------------------------------------------------------------- /package/debian/libdispatch-dev.install: -------------------------------------------------------------------------------- 1 | usr/include/dispatch/* 2 | usr/lib/libdispatch.so 3 | -------------------------------------------------------------------------------- /package/debian/libdispatch.install: -------------------------------------------------------------------------------- 1 | usr/lib/libdispatch.so.* 2 | -------------------------------------------------------------------------------- /package/debian/libdispatch.postrm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -rf /usr/share/doc/libdispatch 3 | -------------------------------------------------------------------------------- /package/debian/libqtdispatch-dev.install: -------------------------------------------------------------------------------- 1 | usr/include/QtDispatch/* 2 | usr/lib/libQtDispatch.so 3 | -------------------------------------------------------------------------------- /package/debian/libqtdispatch.install: -------------------------------------------------------------------------------- 1 | usr/lib/libQtDispatch.so.* -------------------------------------------------------------------------------- /package/debian/libqtdispatch.postrm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -rf /usr/share/doc/libqtdispatch 3 | -------------------------------------------------------------------------------- /package/debian/libxdispatch-dev.install: -------------------------------------------------------------------------------- 1 | usr/include/xdispatch/* 2 | usr/lib/libxdispatch.so 3 | -------------------------------------------------------------------------------- /package/debian/libxdispatch.install: -------------------------------------------------------------------------------- 1 | usr/lib/libxdispatch.so.* -------------------------------------------------------------------------------- /package/debian/libxdispatch.postrm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -rf /usr/share/doc/libxdispatch 3 | -------------------------------------------------------------------------------- /package/debian/package.sh: -------------------------------------------------------------------------------- 1 | # 2 | # package.sh 3 | # 4 | # Copyright (c) 2011-2014 MLBA-Team 5 | # All rights reserved. 6 | # 7 | # @LICENSE_HEADER_START@ 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # @LICENSE_HEADER_END@ 20 | # 21 | 22 | #!/bin/sh 23 | 24 | CONFIG=package/ubuntu 25 | VERSION=$1 26 | BUILDDIR=/tmp/xdispatch 27 | 28 | # copy sources to clean target 29 | echo -- create $BUILDDIR 30 | mkdir -p $BUILDDIR 31 | echo -- copy sources to $BUILDDIR/$VERSION 32 | cp -vrf . $BUILDDIR/$VERSION 33 | CURRENT=`pwd` 34 | cd $BUILDDIR/$VERSION 35 | # remove .svn directories (if any) 36 | echo -- clean svn information 37 | rm -vrf `find . -type d -name .svn` 38 | # delete old build files 39 | echo -- cleaning build directories 40 | rm -vrf build/QtCreator_ProjectFiles build/*MakeFiles build/Docs build/VS10_ProjectFiles* 41 | # copy debian packaging information 42 | echo -- copy packaging information 43 | mkdir -p debian 44 | cp -vrf $CONFIG/* debian 45 | 46 | # build src package 47 | echo -- build source package 48 | dpkg-buildpackage -us -uc -S -rfakeroot 49 | 50 | # build binary packages 51 | echo -- build binaries 52 | 53 | sudo pbuilder build --buildresult $BUILDDIR ../*.dsc 54 | 55 | # copy binaries back to source dir 56 | echo -- retrieve packages 57 | mv *.deb *.dsc *.tar.gz *.changes $CURRENT/../ 58 | cd .. 59 | lintian *.deb 60 | mv *.deb *.dsc *.tar.gz *.changes $CURRENT/../ 61 | 62 | # cleanup 63 | echo -- cleanup 64 | cd $CURRENT 65 | #rm -rf $BUILDDIR 66 | 67 | echo -- DONE 68 | 69 | -------------------------------------------------------------------------------- /package/debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | CC := clang 4 | CXX := clang++ 5 | CMAKE_FLAGS = \ 6 | -DCMAKE_BUILD_TYPE=Release \ 7 | -DSTATIC_KQUEUE=ON \ 8 | -DSTATIC_WORKQUEUE=ON \ 9 | 10 | %: 11 | dh --with quilt $@ --buildsystem=cmake 12 | 13 | override_dh_auto_configure: 14 | dh_auto_configure -- $(CMAKE_FLAGS) 15 | 16 | override_dh_install: 17 | 18 | dh_install -O--buildsystem=cmake 19 | -------------------------------------------------------------------------------- /package/debian/source/format: -------------------------------------------------------------------------------- 1 | 1.0 2 | -------------------------------------------------------------------------------- /package/debian/xdispatch-doc.install: -------------------------------------------------------------------------------- 1 | usr/share/doc/xdispatch-doc/html 2 | -------------------------------------------------------------------------------- /package/debian/xdispatch-doc.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ln -s /usr/share/doc/xdispatch-doc/html /usr/share/doc/libdispatch 3 | ln -s /usr/share/doc/xdispatch-doc/html /usr/share/doc/libxdispatch 4 | ln -s /usr/share/doc/xdispatch-doc/html /usr/share/doc/libqtdispatch 5 | -------------------------------------------------------------------------------- /package/debian/xdispatch-doc.prerm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -f /usr/share/doc/libdispatch/html 3 | rm -f /usr/share/doc/libxdispatch/html 4 | rm -f /usr/share/doc/libqtdispatch/html 5 | -------------------------------------------------------------------------------- /package/osx/pkg.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # pkg.cmake 3 | # 4 | # Copyright (c) 2011-2014 MLBA-Team 5 | # All rights reserved. 6 | # 7 | # @LICENSE_HEADER_START@ 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # @LICENSE_HEADER_END@ 20 | # 21 | 22 | set( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.rtf") 23 | set( CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.rtf") 24 | set( CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.rtf") 25 | set( CPACK_PACKAGING_INSTALL_PREFIX "/") 26 | set( CPACK_OSX_PACKAGE_VERSION "10.6") 27 | 28 | 29 | message("-- Configured generator 'PackageMaker'") 30 | set( XDISPATCH_CPACK ${XDISPATCH_CPACK} PackageMaker ) 31 | -------------------------------------------------------------------------------- /package/rpm/rpm.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # rpm.cmake 3 | # 4 | # Copyright (c) 2011-2014 MLBA-Team 5 | # All rights reserved. 6 | # 7 | # @LICENSE_HEADER_START@ 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # @LICENSE_HEADER_END@ 20 | # 21 | 22 | # set( CPACK_RPM_PACKAGE_NAME "xdispatch") 23 | set( CPACK_RPM_PACKAGE_VERSION "${XDISPATCH_VERSION}.${PACKAGE_COMPILER}") 24 | set( CPACK_RPM_PACKAGE_LICENSE "${XDISPATCH_LICENSE}") 25 | set( CPACK_RPM_PACKAGE_REQUIRES "glibc") 26 | set( CPACK_RPM_PACKAGE_VENDOR "mlba-team.de" ) 27 | if(MZ_IS_64BIT) 28 | set( CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") 29 | else() 30 | set( CPACK_RPM_PACKAGE_ARCHITECTURE "x86") 31 | endif() 32 | set( CPACK_RPM_COMPONENT_INSTALL ON) 33 | 34 | message("-- Configured generator 'RPM'") 35 | set( XDISPATCH_CPACK ${XDISPATCH_CPACK} RPM ) 36 | -------------------------------------------------------------------------------- /package/ubuntu/README.Debian: -------------------------------------------------------------------------------- 1 | Notes for the Debian xdispatch packages: 2 | 3 | To compile code against libdispatch, use: 4 | 5 | gcc -c code.c -o code.o -ldispatch 6 | 7 | To compile code against libxdispatch, use: 8 | 9 | g++ -c code.cpp -o code.o -lxdispatch -ldispatch 10 | 11 | -------------------------------------------------------------------------------- /package/ubuntu/README.source: -------------------------------------------------------------------------------- 1 | README.source 2 | 3 | The source package uses quilt to manage all modifications to the upstream 4 | source. Changes are stored in the source package as diffs in debian/patches 5 | and applied during the build. 6 | 7 | See /usr/share/doc/quilt/README.source for a detailed explanation. 8 | 9 | -------------------------------------------------------------------------------- /package/ubuntu/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /package/ubuntu/deb.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # deb.cmake 3 | # 4 | # Copyright (c) 2011-2014 MLBA-Team 5 | # All rights reserved. 6 | # 7 | # @LICENSE_HEADER_START@ 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # @LICENSE_HEADER_END@ 20 | # 21 | 22 | add_custom_target( 23 | ubuntu ./package/ubuntu/package.sh xdispatch-${XDISPATCH_VERSION} 24 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 25 | ) 26 | 27 | configure_file( 28 | ${CMAKE_CURRENT_SOURCE_DIR}/package/ubuntu/changelog.in 29 | ${CMAKE_CURRENT_SOURCE_DIR}/package/ubuntu/changelog 30 | ) 31 | 32 | 33 | message("-- Configured generator 'DEB (Ubuntu)'") 34 | set( XDISPATCH_CPACK ${XDISPATCH_CPACK} DEB ) 35 | -------------------------------------------------------------------------------- /package/ubuntu/libdispatch-dev.install: -------------------------------------------------------------------------------- 1 | usr/include/dispatch/* 2 | usr/lib/libdispatch.so 3 | -------------------------------------------------------------------------------- /package/ubuntu/libdispatch.install: -------------------------------------------------------------------------------- 1 | usr/lib/libdispatch.so.* 2 | -------------------------------------------------------------------------------- /package/ubuntu/libdispatch.postrm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -rf /usr/share/doc/libdispatch 3 | -------------------------------------------------------------------------------- /package/ubuntu/libqtdispatch-dev.install: -------------------------------------------------------------------------------- 1 | usr/include/QtDispatch/* 2 | usr/lib/libQtDispatch.so 3 | -------------------------------------------------------------------------------- /package/ubuntu/libqtdispatch.install: -------------------------------------------------------------------------------- 1 | usr/lib/libQtDispatch.so.* -------------------------------------------------------------------------------- /package/ubuntu/libqtdispatch.postrm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -rf /usr/share/doc/libqtdispatch 3 | -------------------------------------------------------------------------------- /package/ubuntu/libxdispatch-dev.install: -------------------------------------------------------------------------------- 1 | usr/include/xdispatch/* 2 | usr/lib/libxdispatch.so 3 | -------------------------------------------------------------------------------- /package/ubuntu/libxdispatch.install: -------------------------------------------------------------------------------- 1 | usr/lib/libxdispatch.so.* -------------------------------------------------------------------------------- /package/ubuntu/libxdispatch.postrm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -rf /usr/share/doc/libxdispatch 3 | -------------------------------------------------------------------------------- /package/ubuntu/package.sh: -------------------------------------------------------------------------------- 1 | # 2 | # package.sh 3 | # 4 | # Copyright (c) 2011-2014 MLBA-Team 5 | # All rights reserved. 6 | # 7 | # @LICENSE_HEADER_START@ 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # @LICENSE_HEADER_END@ 20 | # 21 | 22 | #!/bin/sh 23 | 24 | CONFIG=package/ubuntu 25 | VERSION=$1 26 | BUILDDIR=/tmp/xdispatch 27 | 28 | # copy sources to clean target 29 | echo -- create $BUILDDIR 30 | mkdir -p $BUILDDIR 31 | echo -- copy sources to $BUILDDIR/$VERSION 32 | cp -vrf . $BUILDDIR/$VERSION 33 | CURRENT=`pwd` 34 | cd $BUILDDIR/$VERSION 35 | # remove .svn directories (if any) 36 | echo -- clean svn information 37 | rm -vrf `find . -type d -name .svn` 38 | # delete old build files 39 | echo -- cleaning build directories 40 | rm -vrf build/QtCreator_ProjectFiles build/*MakeFiles build/Docs build/VS10_ProjectFiles* 41 | # copy debian packaging information 42 | echo -- copy packaging information 43 | mkdir -p debian 44 | cp -vrf $CONFIG/* debian 45 | 46 | # build src package 47 | echo -- build source package 48 | dpkg-buildpackage -us -uc -S -rfakeroot 49 | 50 | # build binary packages 51 | echo -- build binaries 52 | 53 | sudo pbuilder build --buildresult $BUILDDIR ../*.dsc 54 | 55 | # copy binaries back to source dir 56 | echo -- retrieve packages 57 | mv *.deb *.dsc *.tar.gz *.changes $CURRENT/../ 58 | cd .. 59 | lintian *.deb 60 | mv *.deb *.dsc *.tar.gz *.changes $CURRENT/../ 61 | 62 | # cleanup 63 | echo -- cleanup 64 | cd $CURRENT 65 | #rm -rf $BUILDDIR 66 | 67 | echo -- DONE 68 | 69 | -------------------------------------------------------------------------------- /package/ubuntu/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | CC := clang 4 | CXX := clang++ 5 | CMAKE_FLAGS = \ 6 | -DCMAKE_C_COMPILER=clang \ 7 | -DCMAKE_CXX_COMPILER=clang++ \ 8 | -DCMAKE_BUILD_TYPE=Release \ 9 | -DSTATIC_KQUEUE=ON \ 10 | -DSTATIC_WORKQUEUE=ON \ 11 | -DXDISPATCH_DOCS=ON 12 | 13 | %: 14 | dh --with quilt $@ --buildsystem=cmake 15 | 16 | override_dh_auto_configure: 17 | dh_auto_configure -- $(CMAKE_FLAGS) 18 | 19 | override_dh_install: 20 | 21 | dh_install -O--buildsystem=cmake 22 | -------------------------------------------------------------------------------- /package/ubuntu/source/format: -------------------------------------------------------------------------------- 1 | 1.0 2 | -------------------------------------------------------------------------------- /package/ubuntu/xdispatch-doc.install: -------------------------------------------------------------------------------- 1 | usr/share/doc/xdispatch-doc/html 2 | -------------------------------------------------------------------------------- /package/ubuntu/xdispatch-doc.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ln -s /usr/share/doc/xdispatch-doc/html /usr/share/doc/libdispatch 3 | ln -s /usr/share/doc/xdispatch-doc/html /usr/share/doc/libxdispatch 4 | ln -s /usr/share/doc/xdispatch-doc/html /usr/share/doc/libqtdispatch 5 | -------------------------------------------------------------------------------- /package/ubuntu/xdispatch-doc.prerm: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -f /usr/share/doc/libdispatch/html 3 | rm -f /usr/share/doc/libxdispatch/html 4 | rm -f /usr/share/doc/libqtdispatch/html 5 | -------------------------------------------------------------------------------- /package/windows/zip.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # zip.cmake 3 | # 4 | # Copyright (c) 2011-2014 MLBA-Team 5 | # All rights reserved. 6 | # 7 | # @LICENSE_HEADER_START@ 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # @LICENSE_HEADER_END@ 20 | # 21 | 22 | install(FILES 23 | ${CMAKE_CURRENT_SOURCE_DIR}/README.dox 24 | ${CMAKE_CURRENT_SOURCE_DIR}/CHANGELOG.dox 25 | ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE 26 | ${CMAKE_CURRENT_SOURCE_DIR}/NOTICE 27 | ${CMAKE_CURRENT_SOURCE_DIR}/TODO.txt 28 | DESTINATION .) 29 | 30 | -------------------------------------------------------------------------------- /tests/Qt_dispatch_cascade_blocks.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Qt_dispatch_cascade_blocks.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | 24 | #include 25 | #include "Qt_tests.h" 26 | 27 | /* 28 | Little tests mainly checking the correct mapping of the Qt api 29 | to the underlying C Api 30 | */ 31 | 32 | extern "C" void Qt_dispatch_cascade_blocks(){ 33 | QTDISPATCH_decl_argv_argc; 34 | QDispatchApplication app(argc, argv); 35 | 36 | MU_BEGIN_TEST(Qt_dispatch_cascade_blocks); 37 | 38 | QDispatchQueue q = QDispatch::globalQueue(QDispatch::DEFAULT); 39 | MU_ASSERT_NOT_NULL(q.native()); 40 | 41 | int no = 0; 42 | 43 | q.async(new QBlockRunnable(^{ 44 | int no2 = no+100; 45 | QDispatchQueue c = QDispatch::currentQueue(); 46 | c.async(new QBlockRunnable(^{ 47 | int no3 = no2+20; 48 | QDispatch::currentQueue().async(new QBlockRunnable(^{ 49 | int no4 = no3+3 ; 50 | QDispatch::currentQueue().async(new QBlockRunnable(^{ 51 | MU_ASSERT_EQUAL(no4,123); 52 | MU_PASS("And Out"); 53 | })); 54 | })); 55 | })); 56 | })); 57 | 58 | app.exec(); 59 | MU_END_TEST; 60 | } 61 | -------------------------------------------------------------------------------- /tests/Qt_dispatch_cascade_lambda.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Qt_dispatch_cascade_lambda.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include 24 | #include "Qt_tests.h" 25 | 26 | /* 27 | Little tests mainly checking the correct mapping of the Qt api 28 | to the underlying C Api 29 | */ 30 | 31 | extern "C" void Qt_dispatch_cascade_lambda(){ 32 | QTDISPATCH_decl_argv_argc; 33 | QDispatchApplication app(argc, argv); 34 | 35 | MU_BEGIN_TEST(Qt_dispatch_cascade_lambda); 36 | 37 | QDispatchQueue q = QDispatch::globalQueue(QDispatch::DEFAULT); 38 | MU_ASSERT_NOT_NULL(q.native()); 39 | 40 | int no = 0; 41 | 42 | q.async(QDispatchMakeRunnable([=]{ 43 | int no2 = no+100; 44 | QDispatchQueue c = QDispatch::currentQueue(); 45 | c.async(QDispatchMakeRunnable([=]{ 46 | int no3 = no2+20; 47 | QDispatch::currentQueue().async(QDispatchMakeRunnable([=]{ 48 | int no4 = no3+3 ; 49 | QDispatch::currentQueue().async(QDispatchMakeRunnable([=]{ 50 | MU_ASSERT_EQUAL(no4,123); 51 | MU_PASS("And Out"); 52 | })); 53 | })); 54 | })); 55 | })); 56 | 57 | app.exec(); 58 | MU_END_TEST; 59 | } 60 | -------------------------------------------------------------------------------- /tests/Qt_dispatch_current_blocks.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008-2009 Apple Inc. All rights reserved. 3 | * Copyright (c) 2011-2013 MLBA-Team. All rights reserved. 4 | * 5 | * @MLBA_OPEN_LICENSE_HEADER_START@ 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * @MLBA_OPEN_LICENSE_HEADER_END@ 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "Qt_tests.h" 27 | 28 | /* 29 | Little tests mainly checking the correct mapping of the Qt api 30 | to the underlying C Api 31 | */ 32 | 33 | extern "C" void Qt_dispatch_current_blocks(){ 34 | QTDISPATCH_decl_argv_argc; 35 | QDispatchApplication app(argc, argv); 36 | 37 | MU_BEGIN_TEST(Qt_dispatch_current_blocks); 38 | 39 | QDispatch::globalQueue().async(^{ 40 | QTest::qSleep(10); 41 | MU_MESSAGE("Queue should be global default queue"); 42 | qDebug() << QDispatch::currentQueue(); 43 | QDispatch::mainQueue().async(new QBlockRunnable(^{ 44 | QTest::qSleep(10); 45 | MU_MESSAGE("Queue should be main queue"); 46 | qDebug() << QDispatch::currentQueue(); 47 | 48 | MU_PASS(""); 49 | })); 50 | }); 51 | 52 | app.exec(); 53 | MU_END_TEST; 54 | } 55 | -------------------------------------------------------------------------------- /tests/Qt_dispatch_current_lambda.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2008-2009 Apple Inc. All rights reserved. 3 | * Copyright (c) 2011-2013 MLBA-Team. All rights reserved. 4 | * 5 | * @MLBA_OPEN_LICENSE_HEADER_START@ 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * 19 | * @MLBA_OPEN_LICENSE_HEADER_END@ 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "Qt_tests.h" 27 | 28 | /* 29 | Little tests mainly checking the correct mapping of the Qt api 30 | to the underlying C Api 31 | */ 32 | 33 | extern "C" void Qt_dispatch_current_lambda(){ 34 | QTDISPATCH_decl_argv_argc; 35 | QDispatchApplication app(argc, argv); 36 | 37 | MU_BEGIN_TEST(Qt_dispatch_current_lambda); 38 | 39 | QDispatch::globalQueue().async([=]{ 40 | QTest::qSleep(10); 41 | MU_MESSAGE("Queue should be global default queue"); 42 | qDebug() << QDispatch::currentQueue(); 43 | QDispatch::mainQueue().async(QDispatchMakeRunnable([=]{ 44 | QTest::qSleep(10); 45 | MU_MESSAGE("Queue should be main queue"); 46 | qDebug() << QDispatch::currentQueue(); 47 | 48 | MU_PASS(""); 49 | })); 50 | }); 51 | 52 | app.exec(); 53 | MU_END_TEST; 54 | } 55 | -------------------------------------------------------------------------------- /tests/Qt_dispatch_debug.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Qt_dispatch_debug.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | #include "Qt_tests.h" 27 | 28 | /* 29 | Little tests mainly checking the correct mapping of the Qt api 30 | to the underlying C Api 31 | */ 32 | 33 | extern "C" void Qt_dispatch_debug(){ 34 | 35 | 36 | MU_BEGIN_TEST(Qt_dispatch_debug); 37 | 38 | QDispatchQueue q = QDispatch::mainQueue(); 39 | QDispatchGroup g; 40 | QDispatchSemaphore s(0); 41 | 42 | MU_MESSAGE("Begin testing debug output using QDebug()"); 43 | 44 | qDebug() << q; 45 | qDebug() << g; 46 | qDebug() << s; 47 | 48 | MU_MESSAGE("All output done."); 49 | 50 | MU_END_TEST; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /tests/Qt_dispatch_queue_blocks.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Qt_dispatch_queue_blocks.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | 24 | #include 25 | 26 | #include "Qt_tests.h" 27 | 28 | 29 | #define RUN_TIMES 20 30 | 31 | /* 32 | Little tests mainly checking the correct mapping of the Qt api 33 | to the underlying C Api 34 | */ 35 | 36 | extern "C" void Qt_dispatch_queue_blocks(){ 37 | QTDISPATCH_decl_argv_argc; 38 | QDispatchApplication app(argc, argv); 39 | 40 | MU_BEGIN_TEST(Qt_dispatch_queue_blocks); 41 | 42 | uintptr_t* worker = new uintptr_t; 43 | *worker = 0; 44 | 45 | QDispatchQueue q = QDispatch::globalQueue(QDispatch::DEFAULT); 46 | MU_ASSERT_NOT_NULL(q.native()); 47 | 48 | q.apply(RUN_TIMES, new QIterationBlockRunnable(^(size_t i){ 49 | dispatch_atomic_inc(worker); 50 | })); 51 | 52 | QDispatch::globalQueue(QDispatch::LOW).async(new QBlockRunnable(^{ 53 | MU_ASSERT_EQUAL(*worker,RUN_TIMES); 54 | MU_PASS("Queue executed"); 55 | })); 56 | 57 | app.exec(); 58 | MU_END_TEST; 59 | } 60 | -------------------------------------------------------------------------------- /tests/Qt_dispatch_queue_lambda.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Qt_dispatch_queue_lambda.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | 24 | #include 25 | 26 | #include "Qt_tests.h" 27 | 28 | 29 | #define RUN_TIMES 20 30 | 31 | /* 32 | Little tests mainly checking the correct mapping of the Qt api 33 | to the underlying C Api 34 | */ 35 | 36 | extern "C" void Qt_dispatch_queue_lambda(){ 37 | QTDISPATCH_decl_argv_argc; 38 | QDispatchApplication app(argc, argv); 39 | 40 | MU_BEGIN_TEST(Qt_dispatch_queue_lambda); 41 | 42 | uintptr_t* worker = new uintptr_t; 43 | *worker = 0; 44 | 45 | QDispatchQueue q = QDispatch::globalQueue(QDispatch::DEFAULT); 46 | MU_ASSERT_NOT_NULL(q.native()); 47 | 48 | q.apply(RUN_TIMES, QDispatchMakeIterationRunnable([=](size_t i){ 49 | dispatch_atomic_inc(worker); 50 | })); 51 | 52 | QDispatch::globalQueue(QDispatch::LOW).async(QDispatchMakeRunnable([=]{ 53 | MU_ASSERT_EQUAL(*worker,RUN_TIMES); 54 | MU_PASS("Queue executed"); 55 | })); 56 | 57 | app.exec(); 58 | MU_END_TEST; 59 | } 60 | 61 | -------------------------------------------------------------------------------- /tests/Qt_dispatch_semaphore_blocks.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Qt_dispatch_semaphore_blocks.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include "Qt_tests.h" 29 | 30 | #define LAPS 10000 31 | 32 | /* 33 | Little tests mainly checking the correct mapping of the Qt api 34 | to the underlying C Api 35 | */ 36 | 37 | extern "C" void Qt_dispatch_semaphore_blocks(){ 38 | static size_t total; 39 | 40 | MU_BEGIN_TEST(Qt_dispatch_semaphore_blocks); 41 | QDispatchSemaphore* dsema = new QDispatchSemaphore(1); 42 | 43 | QDispatchQueue("Qt_dispatch_semaphore").apply(LAPS, ^(size_t idx) { 44 | dsema->try_acquire(DISPATCH_TIME_FOREVER); 45 | total++; 46 | dsema->release(); 47 | }); 48 | 49 | delete dsema; 50 | 51 | MU_ASSERT_EQUAL(total, LAPS); 52 | 53 | MU_PASS(""); 54 | MU_END_TEST; 55 | } 56 | -------------------------------------------------------------------------------- /tests/Qt_dispatch_semaphore_lambda.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Qt_dispatch_semaphore_lambda.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include "Qt_tests.h" 28 | 29 | #define LAPS 10000 30 | 31 | /* 32 | Little tests mainly checking the correct mapping of the Qt api 33 | to the underlying C Api 34 | */ 35 | 36 | extern "C" void Qt_dispatch_semaphore_lambda(){ 37 | static size_t total; 38 | 39 | MU_BEGIN_TEST(Qt_dispatch_semaphore_lambda); 40 | QDispatchSemaphore* dsema = new QDispatchSemaphore(1); 41 | 42 | QDispatchQueue("Qt_dispatch_semaphore").apply( 43 | LAPS, 44 | [=](size_t idx) { 45 | dsema->try_acquire(DISPATCH_TIME_FOREVER); 46 | total++; 47 | dsema->release(); 48 | } 49 | ); 50 | 51 | delete dsema; 52 | 53 | MU_ASSERT_EQUAL(total, LAPS); 54 | 55 | MU_PASS(""); 56 | MU_END_TEST; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /tests/Qt_dispatch_serialqueue_blocks.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Qt_dispatch_serialqueue_blocks.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | #include "Qt_tests.h" 27 | 28 | 29 | #define JOBS_NO 20 30 | 31 | #if TARGET_OS_EMBEDDED 32 | #define LOOP_COUNT 2000000 33 | #else 34 | #define LOOP_COUNT 100000 35 | #endif 36 | 37 | /* 38 | Little tests mainly checking the correct mapping of the Qt api 39 | to the underlying C Api 40 | */ 41 | 42 | extern "C" void Qt_dispatch_serialqueue_blocks(){ 43 | QTDISPATCH_decl_argv_argc; 44 | QDispatchApplication app(argc, argv); 45 | 46 | MU_BEGIN_TEST(Qt_dispatch_serialqueue_blocks); 47 | 48 | unsigned int* worker = new unsigned int; 49 | *worker = 0; 50 | 51 | QDispatchQueue q("Qt_dispatch_serialqueue"); 52 | 53 | // dispatch some jobs 54 | for(unsigned int x = 0; x < JOBS_NO; x++) { 55 | q.async(new QBlockRunnable(^{ 56 | MU_ASSERT_EQUAL(*worker,x); 57 | // keep cpu busy 58 | for(int i = 0; i < LOOP_COUNT;i++); 59 | *worker = x+1; 60 | })); 61 | 62 | } 63 | 64 | q.async(new QBlockRunnable(^{ 65 | MU_ASSERT_EQUAL(*worker,JOBS_NO); 66 | // Test passed 67 | MU_PASS("Blocks were executed in correct order"); 68 | })); 69 | 70 | app.exec(); 71 | MU_END_TEST; 72 | } 73 | -------------------------------------------------------------------------------- /tests/Qt_dispatch_serialqueue_lambda.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Qt_dispatch_serialqueue_lambda.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | 24 | #include 25 | #include 26 | 27 | #include "Qt_tests.h" 28 | 29 | 30 | #define JOBS_NO 20 31 | 32 | #if TARGET_OS_EMBEDDED 33 | #define LOOP_COUNT 2000000 34 | #else 35 | #define LOOP_COUNT 100000 36 | #endif 37 | 38 | /* 39 | Little tests mainly checking the correct mapping of the Qt api 40 | to the underlying C Api 41 | */ 42 | 43 | extern "C" void Qt_dispatch_serialqueue_lambda(){ 44 | QTDISPATCH_decl_argv_argc; 45 | QDispatchApplication app(argc, argv); 46 | 47 | MU_BEGIN_TEST(Qt_dispatch_serialqueue_lambda); 48 | 49 | unsigned int* worker = new unsigned int; 50 | *worker = 0; 51 | 52 | QDispatchQueue q("Qt_dispatch_serialqueue"); 53 | 54 | // dispatch some jobs 55 | for(unsigned int x = 0; x < JOBS_NO; x++) { 56 | q.async(QDispatchMakeRunnable([=]{ 57 | MU_ASSERT_EQUAL(*worker,x); 58 | // keep cpu busy 59 | for(int i = 0; i < LOOP_COUNT;i++); 60 | *worker = x+1; 61 | })); 62 | 63 | } 64 | 65 | q.async(QDispatchMakeRunnable([=]{ 66 | MU_ASSERT_EQUAL(*worker,JOBS_NO); 67 | // Test passed 68 | MU_PASS("Blocks were executed in correct order"); 69 | })); 70 | 71 | app.exec(); 72 | MU_END_TEST; 73 | } 74 | -------------------------------------------------------------------------------- /tests/Qt_dispatch_source_device.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Qt_dispatch_source_device.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include "Qt_tests.h" 29 | 30 | /* 31 | Tests the source type IODevice 32 | */ 33 | 34 | extern "C" void Qt_dispatch_source_device(){ 35 | QTDISPATCH_decl_argv_argc; 36 | QDispatchApplication app(argc, argv); 37 | 38 | MU_BEGIN_TEST(Qt_dispatch_source_device); 39 | 40 | // TODO How? to test this? 41 | QFile f; 42 | QDispatchSource src(new QDispatchSourceTypeIODevice(&f)); 43 | src.resume(); 44 | MU_PASS(""); 45 | 46 | app.exec(); 47 | MU_END_TEST; 48 | } 49 | -------------------------------------------------------------------------------- /tests/Qt_dispatch_source_network_blocks.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Qt_dispatch_source_network_blocks.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "Qt_tests.h" 30 | 31 | 32 | /* 33 | Tests the source type network manager 34 | */ 35 | 36 | extern "C" void Qt_dispatch_source_network_blocks(){ 37 | QTDISPATCH_decl_argv_argc; 38 | QDispatchApplication app(argc, argv); 39 | 40 | MU_BEGIN_TEST(Qt_dispatch_source_network_blocks); 41 | 42 | // configure the source 43 | QNetworkAccessManager* man = new QNetworkAccessManager(); 44 | QDispatchSource src(new QDispatchSourceTypeNetworkManager(man)); 45 | src.setHandler(^{ 46 | 47 | QNetworkReply* r = QDispatchSource::data(); 48 | MU_ASSERT_NOT_NULL(r); 49 | 50 | 51 | QString content = r->readAll(); 52 | if(content.isEmpty()) 53 | content = (r->readAll()); 54 | MU_MESSAGE("Received response contains:"); 55 | qDebug() << "\t\t" << content; 56 | 57 | r->deleteLater(); 58 | MU_PASS(""); 59 | }); 60 | 61 | // now post a request 62 | man->get(QNetworkRequest(QUrl("http://www.google.com"))); 63 | 64 | app.exec(); 65 | MU_END_TEST; 66 | } 67 | -------------------------------------------------------------------------------- /tests/Qt_dispatch_source_network_lambda.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Qt_dispatch_source_network_lambda.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "Qt_tests.h" 30 | 31 | /* 32 | Tests the source type network manager 33 | */ 34 | 35 | extern "C" void Qt_dispatch_source_network_lambda(){ 36 | QTDISPATCH_decl_argv_argc; 37 | QDispatchApplication app(argc, argv); 38 | 39 | MU_BEGIN_TEST(Qt_dispatch_source_network_lambda); 40 | 41 | // configure the source 42 | QNetworkAccessManager* man = new QNetworkAccessManager(); 43 | QDispatchSource src(new QDispatchSourceTypeNetworkManager(man)); 44 | src.setHandler([=]{ 45 | 46 | QNetworkReply* r = QDispatchSource::data(); 47 | MU_ASSERT_NOT_NULL(r); 48 | 49 | 50 | QString content = r->readAll(); 51 | if(content.isEmpty()) 52 | content = (r->readAll()); 53 | MU_MESSAGE("Received response contains:"); 54 | qDebug() << "\t\t" << content; 55 | 56 | r->deleteLater(); 57 | MU_PASS(""); 58 | }); 59 | src.resume(); 60 | 61 | // now post a request 62 | man->get(QNetworkRequest(QUrl("http://www.google.com"))); 63 | 64 | app.exec(); 65 | MU_END_TEST; 66 | } 67 | -------------------------------------------------------------------------------- /tests/Qt_dispatch_timeout_blocks.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Qt_dispatch_timeout_blocks.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | #include "Qt_tests.h" 27 | 28 | /* 29 | Little tests mainly checking the correct mapping of the Qt api 30 | to the underlying C Api 31 | */ 32 | 33 | extern "C" void Qt_dispatch_after_blocks(){ 34 | QTime watch; 35 | QTDISPATCH_decl_argv_argc; 36 | QDispatchApplication app(argc, argv); 37 | MU_BEGIN_TEST(Qt_dispatch_after_blocks); 38 | 39 | watch.start(); 40 | 41 | QDispatch::globalQueue(QDispatch::DEFAULT).after(QTime::currentTime().addMSecs(1000), ^{ 42 | MU_MESSAGE("Should finish between 0.5s and 1.5s: %f", watch.elapsed()/1000.0); 43 | MU_ASSERT_GREATER_THAN_EQUAL(watch.elapsed(), 700); 44 | }); 45 | 46 | QDispatch::mainQueue().after(QTime::currentTime().addMSecs(2000), ^{ 47 | MU_MESSAGE("Should finish between 2s and 2.5s: %f", watch.elapsed()/1000.0); 48 | MU_ASSERT_GREATER_THAN_EQUAL(watch.elapsed(), 1800); 49 | MU_PASS(""); 50 | }); 51 | 52 | app.exec(); 53 | MU_END_TEST; 54 | } 55 | -------------------------------------------------------------------------------- /tests/Qt_dispatch_timeout_lambda.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Qt_dispatch_timeout_lambda.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | #include "Qt_tests.h" 27 | 28 | /* 29 | Little tests mainly checking the correct mapping of the Qt api 30 | to the underlying C Api 31 | */ 32 | 33 | extern "C" void Qt_dispatch_after_lambda(){ 34 | QTime watch; 35 | QTDISPATCH_decl_argv_argc; 36 | QDispatchApplication app(argc, argv); 37 | 38 | MU_BEGIN_TEST(Qt_dispatch_after_lambda); 39 | 40 | watch.start(); 41 | 42 | QDispatch::globalQueue(QDispatch::DEFAULT).after( 43 | QTime::currentTime().addMSecs(1000), 44 | [=]{ 45 | MU_MESSAGE("Should finish between 0.5s and 1.5s: %f", watch.elapsed()/1000.0); 46 | MU_ASSERT_GREATER_THAN_EQUAL(watch.elapsed(), 700); 47 | } 48 | ); 49 | 50 | QDispatch::mainQueue().after( 51 | QTime::currentTime().addMSecs(2000), 52 | [=]{ 53 | MU_MESSAGE("Should finish between 2s and 2.5s: %f", watch.elapsed()/1000.0); 54 | MU_ASSERT_GREATER_THAN_EQUAL(watch.elapsed(), 1800); 55 | MU_PASS(""); 56 | } 57 | ); 58 | 59 | app.exec(); 60 | MU_END_TEST; 61 | } 62 | -------------------------------------------------------------------------------- /tests/Qt_early_dispatch_blocks.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Qt_early_dispatch_blocks.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | 24 | 25 | #include 26 | #include 27 | 28 | #include "Qt_tests.h" 29 | 30 | /* 31 | Verify that jobs dispatched before creation 32 | of the QDispatchApplication are properly processed 33 | */ 34 | 35 | extern "C" void Qt_early_dispatch1_blocks(){ 36 | MU_BEGIN_TEST(Qt_early_dispatch1_blocks); 37 | 38 | QDispatchQueue q = QDispatch::mainQueue(); 39 | MU_ASSERT_NOT_NULL( q.native() ); 40 | q.async( ^{ MU_PASS(""); } ); 41 | 42 | char argv[] = "test"; 43 | int argc = 1; 44 | QDispatchApplication app(argc, (char**)&argv); 45 | 46 | app.exec(); 47 | MU_END_TEST; 48 | } 49 | 50 | extern "C" void Qt_early_dispatch2_blocks(){ 51 | MU_BEGIN_TEST(Qt_early_dispatch2_blocks); 52 | 53 | QDispatchQueue q = QDispatch::mainQueue(); 54 | MU_ASSERT_NOT_NULL( q.native() ); 55 | q.async( ^{ MU_PASS(""); } ); 56 | 57 | QTDISPATCH_decl_argv_argc; 58 | QDispatchApplication app(argc, argv); 59 | 60 | app.exec(); 61 | MU_END_TEST; 62 | } 63 | -------------------------------------------------------------------------------- /tests/Qt_early_dispatch_lambda.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Qt_early_dispatch_lambda.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | 24 | #include 25 | #include 26 | 27 | #include "Qt_tests.h" 28 | 29 | /* 30 | Verify that jobs dispatched before creation 31 | of the QDispatchApplication are properly processed 32 | */ 33 | 34 | extern "C" void Qt_early_dispatch1_lambda(){ 35 | MU_BEGIN_TEST(Qt_early_dispatch1_lambda); 36 | 37 | QDispatchQueue q = QDispatch::mainQueue(); 38 | MU_ASSERT_NOT_NULL( q.native() ); 39 | q.async( [=]{ MU_PASS(""); } ); 40 | 41 | QTDISPATCH_decl_argv_argc; 42 | QDispatchApplication app(argc, argv); 43 | 44 | app.exec(); 45 | MU_END_TEST; 46 | } 47 | 48 | extern "C" void Qt_early_dispatch2_lambda(){ 49 | MU_BEGIN_TEST(Qt_early_dispatch2_lambda); 50 | 51 | QDispatchQueue q = QDispatch::mainQueue(); 52 | MU_ASSERT_NOT_NULL( q.native() ); 53 | q.async( [=]{ MU_PASS(""); } ); 54 | 55 | char argv[] = "test"; 56 | int argc = 1; 57 | QDispatchCoreApplication app(argc, (char**)&argv); 58 | 59 | app.exec(); 60 | MU_END_TEST; 61 | } 62 | -------------------------------------------------------------------------------- /tests/checks/blocks.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2013 MLBA-Team. All rights reserved. 3 | * 4 | * @MLBA_OPEN_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 | * @MLBA_OPEN_LICENSE_HEADER_END@ 19 | */ 20 | 21 | #ifndef __BLOCKS__ 22 | # error "no blocks" 23 | #endif 24 | 25 | int main(int argc, char* argv[]) 26 | { 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /tests/checks/lambdas.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2012-2013 MLBA-Team. All rights reserved. 3 | * 4 | * @MLBA_OPEN_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 | * @MLBA_OPEN_LICENSE_HEADER_END@ 19 | */ 20 | 21 | 22 | #include 23 | 24 | int main(int argc, char* argv[]) { 25 | auto func = []{ 26 | int eins = 1; 27 | int zwei = 2*eins; 28 | std::cout << zwei << std::endl; 29 | }; 30 | (void)func; 31 | } 32 | -------------------------------------------------------------------------------- /tests/cxx_dispatch_cascade_blocks.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * cxx_dispatch_cascade_blocks.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | 24 | #include 25 | #include "cxx_tests.h" 26 | 27 | 28 | /* 29 | Little tests mainly checking the correct mapping of the c++ api 30 | to the underlying C Api 31 | */ 32 | 33 | extern "C" void cxx_dispatch_cascade_blocks(){ 34 | 35 | MU_BEGIN_TEST(cxx_dispatch_cascade_blocks); 36 | 37 | xdispatch::queue q = xdispatch::global_queue(); 38 | MU_ASSERT_NOT_NULL_HEX(q.native()); 39 | 40 | int no = 0; 41 | 42 | q.async(^{ 43 | MU_ASSERT_EQUAL(no, 0); 44 | int no2 = no+100; 45 | xdispatch::queue c = xdispatch::current_queue(); 46 | c.async(^{ 47 | MU_ASSERT_EQUAL(no2, 100); 48 | int no3 = no2+20; 49 | xdispatch::current_queue().async(^{ 50 | MU_ASSERT_EQUAL(no3, 120); 51 | int no4 = no3+3 ; 52 | xdispatch::current_queue().async(^{ 53 | MU_ASSERT_EQUAL(no4,123); 54 | MU_PASS("And Out"); 55 | }); 56 | }); 57 | }); 58 | }); 59 | 60 | xdispatch::exec(); 61 | MU_END_TEST; 62 | } 63 | 64 | -------------------------------------------------------------------------------- /tests/cxx_dispatch_cascade_lambda.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * cxx_dispatch_cascade_lambda.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | 24 | #include 25 | #include "cxx_tests.h" 26 | 27 | /* 28 | Little tests mainly checking the correct mapping of the c++ api 29 | to the underlying C Api 30 | */ 31 | 32 | extern "C" void cxx_dispatch_cascade_lambda(){ 33 | 34 | MU_BEGIN_TEST(cxx_dispatch_cascade_lambda); 35 | 36 | xdispatch::queue q = xdispatch::global_queue(); 37 | MU_ASSERT_NOT_NULL_HEX(q.native()); 38 | 39 | int no = 0; 40 | 41 | q.async([=]{ 42 | MU_ASSERT_EQUAL(no, 0); 43 | int no2 = no+100; 44 | xdispatch::queue c = xdispatch::current_queue(); 45 | c.async([=]{ 46 | MU_ASSERT_EQUAL(no2, 100); 47 | int no3 = no2+20; 48 | xdispatch::current_queue().async([=]{ 49 | MU_ASSERT_EQUAL(no3, 120); 50 | int no4 = no3+3 ; 51 | xdispatch::current_queue().async([=]{ 52 | MU_ASSERT_EQUAL(no4,123); 53 | MU_PASS("And Out"); 54 | }); 55 | }); 56 | }); 57 | }); 58 | 59 | xdispatch::exec(); 60 | MU_END_TEST; 61 | } 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /tests/cxx_dispatch_current.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * cxx_dispatch_current.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | 24 | #include 25 | #include "cxx_tests.h" 26 | 27 | #include 28 | 29 | /* 30 | Little tests mainly checking the correct mapping of the c++ api 31 | to the underlying C Api 32 | */ 33 | 34 | class main_queue : public xdispatch::operation { 35 | public: 36 | void operator()() { 37 | MU_MESSAGE("Queue should be main queue"); 38 | std::cout << xdispatch::current_queue() << std::endl; 39 | 40 | MU_PASS(""); 41 | } 42 | }; 43 | 44 | class global_queue : public xdispatch::operation { 45 | public: 46 | void operator() (){ 47 | MU_MESSAGE("Queue should be global default queue"); 48 | std::cout << xdispatch::current_queue() << std::endl; 49 | 50 | xdispatch::main_queue().async(new main_queue); 51 | } 52 | }; 53 | 54 | extern "C" void cxx_dispatch_current(){ 55 | MU_BEGIN_TEST(cxx_dispatch_current); 56 | 57 | xdispatch::global_queue().async(new global_queue); 58 | 59 | xdispatch::exec(); 60 | MU_END_TEST; 61 | } 62 | -------------------------------------------------------------------------------- /tests/cxx_dispatch_debug.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * cxx_dispatch_debug.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | 24 | #include 25 | #include "cxx_tests.h" 26 | 27 | #include 28 | 29 | /* 30 | Little tests mainly checking the correct mapping of the c++ api 31 | to the underlying C Api 32 | */ 33 | 34 | extern "C" void cxx_dispatch_debug(){ 35 | MU_BEGIN_TEST(cxx_dispatch_debug); 36 | 37 | xdispatch::queue q = xdispatch::main_queue(); 38 | xdispatch::group g; 39 | xdispatch::semaphore s(0); 40 | 41 | MU_MESSAGE("Begin testing debug output using std::cout"); 42 | 43 | std::cout << q << std::endl; 44 | std::cout << g << std::endl; 45 | std::cout << s << std::endl; 46 | 47 | MU_MESSAGE("All output done."); 48 | 49 | MU_END_TEST; 50 | } 51 | -------------------------------------------------------------------------------- /tests/cxx_dispatch_once.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * cxx_dispatch_once.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | 24 | #include 25 | #include "cxx_tests.h" 26 | 27 | 28 | /* 29 | A simple test for ensuring the once 30 | methods are properly working 31 | */ 32 | 33 | class incrementer : public xdispatch::operation { 34 | 35 | public: 36 | incrementer() 37 | : operation(), counter(0) {} 38 | 39 | void operator()(){ 40 | counter++; 41 | } 42 | 43 | int counter; 44 | 45 | }; 46 | 47 | static xdispatch::once x_once_obj; 48 | 49 | extern "C" void cxx_dispatch_once1(){ 50 | MU_BEGIN_TEST(cxx_dispatch_once1); 51 | 52 | incrementer work; 53 | MU_ASSERT_EQUAL( work.counter, 0 ); 54 | x_once_obj( work ); 55 | x_once_obj( work ); 56 | x_once_obj( work ); 57 | x_once_obj( work ); 58 | x_once_obj( work ); 59 | MU_ASSERT_EQUAL( work.counter, 1 ); 60 | 61 | MU_PASS(""); 62 | 63 | MU_END_TEST; 64 | } 65 | -------------------------------------------------------------------------------- /tests/cxx_dispatch_once_lambda.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * cxx_dispatch_once_lambda.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | 24 | #include 25 | #include "cxx_tests.h" 26 | 27 | 28 | /* 29 | A simple test for ensuring the once 30 | methods are properly working 31 | */ 32 | 33 | static xdispatch::once x_once_obj; 34 | 35 | extern "C" void cxx_dispatch_once2_lambda(){ 36 | MU_BEGIN_TEST(cxx_dispatch_once2_lambda); 37 | 38 | int counter = 0; 39 | int* counter_ptr = &counter; 40 | 41 | MU_ASSERT_EQUAL( counter, 0 ); 42 | x_once_obj( [=]{ (*counter_ptr)++; } ); 43 | x_once_obj( [=]{ (*counter_ptr)++; } ); 44 | x_once_obj( [=]{ (*counter_ptr)++; } ); 45 | x_once_obj( [=]{ (*counter_ptr)++; } ); 46 | x_once_obj( [=]{ (*counter_ptr)++; } ); 47 | MU_ASSERT_EQUAL( counter, 1 ); 48 | 49 | MU_PASS(""); 50 | 51 | 52 | MU_END_TEST; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /tests/cxx_dispatch_queue_blocks.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * cxx_dispatch_queue_blocks.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | 24 | #include 25 | #include "cxx_tests.h" 26 | 27 | #include 28 | 29 | #define RUN_TIMES 20 30 | 31 | /* 32 | Little tests mainly checking the correct mapping of the Qt api 33 | to the underlying C Api 34 | */ 35 | 36 | extern "C" void cxx_dispatch_queue_blocks(){ 37 | MU_BEGIN_TEST(cxx_dispatch_queue_blocks); 38 | 39 | uintptr_t* worker = new uintptr_t; 40 | *worker = 0; 41 | 42 | xdispatch::queue q = xdispatch::global_queue(xdispatch::HIGH); 43 | MU_ASSERT_NOT_NULL(q.native()); 44 | 45 | q.apply(RUN_TIMES, ^(size_t i){ 46 | dispatch_atomic_inc(worker); 47 | }); 48 | 49 | xdispatch::global_queue(xdispatch::LOW).async(^{ 50 | MU_ASSERT_EQUAL(*worker,RUN_TIMES); 51 | MU_PASS("Queue executed"); 52 | }); 53 | 54 | xdispatch::exec(); 55 | MU_END_TEST; 56 | } 57 | -------------------------------------------------------------------------------- /tests/cxx_dispatch_queue_lambda.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * cxx_dispatch_queue_lambda.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | 24 | #include 25 | #include "cxx_tests.h" 26 | 27 | #include 28 | 29 | #define RUN_TIMES 20 30 | 31 | 32 | /* 33 | Little tests mainly checking the correct mapping of the Qt api 34 | to the underlying C Api 35 | */ 36 | 37 | extern "C" void cxx_dispatch_queue_lambda(){ 38 | MU_BEGIN_TEST(cxx_dispatch_queue_lambda); 39 | 40 | uintptr_t* worker = new uintptr_t; 41 | *worker = 0; 42 | 43 | xdispatch::queue q = xdispatch::global_queue(xdispatch::HIGH); 44 | MU_ASSERT_NOT_NULL(q.native()); 45 | 46 | q.apply(RUN_TIMES, [=](size_t i){ 47 | dispatch_atomic_inc(worker); 48 | }); 49 | 50 | xdispatch::global_queue(xdispatch::LOW).async([=]{ 51 | MU_ASSERT_EQUAL(*worker,RUN_TIMES); 52 | MU_PASS("Queue executed"); 53 | }); 54 | 55 | xdispatch::exec(); 56 | MU_END_TEST; 57 | } 58 | -------------------------------------------------------------------------------- /tests/cxx_dispatch_semaphore.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * cxx_dispatch_semaphore.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | 24 | #include 25 | #include "cxx_tests.h" 26 | 27 | #include 28 | 29 | /* 30 | Little tests mainly checking the correct mapping of the c++ api 31 | to the underlying C Api 32 | */ 33 | 34 | 35 | #define LAPS 10000 36 | 37 | /* 38 | Little tests mainly checking the correct mapping of the Qt api 39 | to the underlying C Api 40 | */ 41 | 42 | class acquire_inc : public xdispatch::iteration_operation { 43 | public: 44 | acquire_inc(xdispatch::semaphore* s, size_t& total) 45 | : dsema(s), total(total) { 46 | } 47 | 48 | void operator ()(size_t i){ 49 | dsema->try_acquire(DISPATCH_TIME_FOREVER); 50 | ++total; 51 | dsema->release(); 52 | } 53 | 54 | xdispatch::semaphore* dsema; 55 | size_t& total; 56 | }; 57 | 58 | extern "C" void cxx_dispatch_semaphore(){ 59 | static size_t total; 60 | 61 | MU_BEGIN_TEST(cxx_dispatch_semaphore); 62 | xdispatch::semaphore* dsema = new xdispatch::semaphore(1); 63 | 64 | xdispatch::queue("cxx_dispatch_semaphore").apply(LAPS, new acquire_inc(dsema, total)); 65 | 66 | delete dsema; 67 | 68 | MU_ASSERT_EQUAL(total, LAPS); 69 | 70 | MU_PASS(""); 71 | MU_END_TEST; 72 | } 73 | 74 | 75 | -------------------------------------------------------------------------------- /tests/cxx_dispatch_serialqueue_blocks.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * cxx_dispatch_serialqueue_blocks.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | 24 | #include 25 | #include "cxx_tests.h" 26 | 27 | #include 28 | 29 | /* 30 | Little tests mainly checking the correct mapping of the c++ api 31 | to the underlying C Api 32 | */ 33 | 34 | 35 | #define JOBS_NO 20 36 | 37 | #if TARGET_OS_EMBEDDED 38 | #define LOOP_COUNT 2000000 39 | #else 40 | #define LOOP_COUNT 100000 41 | #endif 42 | 43 | /* 44 | Little tests mainly checking the correct mapping of the c++ api 45 | to the underlying C Api 46 | */ 47 | 48 | extern "C" void cxx_dispatch_serialqueue_blocks(){ 49 | MU_BEGIN_TEST(cxx_dispatch_serialqueue_blocks); 50 | 51 | unsigned int* worker = new unsigned int; 52 | *worker = 0; 53 | 54 | xdispatch::queue q("cxx_dispatch_serialqueue"); 55 | MU_ASSERT_NOT_NULL(q.native()); 56 | 57 | // dispatch some jobs 58 | for(unsigned int x = 0; x < JOBS_NO; x++) { 59 | q.async(^{ 60 | MU_ASSERT_EQUAL(*worker,x); 61 | // keep cpu busy 62 | for(int i = 0; i < LOOP_COUNT;i++); 63 | *worker = x+1; 64 | }); 65 | 66 | } 67 | 68 | q.sync(^{ 69 | MU_ASSERT_EQUAL(*worker,JOBS_NO); 70 | // Test passed 71 | MU_PASS("Blocks were executed in correct order"); 72 | }); 73 | 74 | xdispatch::exec(); 75 | MU_END_TEST; 76 | } 77 | 78 | -------------------------------------------------------------------------------- /tests/cxx_dispatch_source.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * cxx_dispatch_source.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "tests.h" 29 | 30 | 31 | struct TestType : public xdispatch::sourcetype { 32 | 33 | static TestType* instance; 34 | TestType() : xdispatch::sourcetype() { 35 | instance = this; 36 | } 37 | 38 | void signalFinished(const xdispatch::any& v){ 39 | ready(v); 40 | } 41 | }; 42 | 43 | struct handler : public xdispatch::operation { 44 | void operator ()(){ 45 | MU_ASSERT_TRUE(xdispatch::source::data() == "any working"); 46 | MU_PASS(""); 47 | } 48 | }; 49 | 50 | TestType* TestType::instance = NULL; 51 | 52 | extern "C" void cxx_dispatch_source() { 53 | MU_BEGIN_TEST(cxx_dispatch_source); 54 | 55 | xdispatch::source src(new TestType); 56 | MU_ASSERT_NULL( src.native() ); 57 | src.target_queue(xdispatch::main_queue()); 58 | src.handler(new handler); 59 | 60 | src.resume(); 61 | 62 | TestType::instance->signalFinished(std::string("any working")); 63 | xdispatch::exec(); 64 | 65 | MU_END_TEST 66 | } 67 | 68 | -------------------------------------------------------------------------------- /tests/cxx_dispatch_source_blocks.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * cxx_dispatch_source_blocks.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "tests.h" 29 | 30 | struct TestTypeBlocks : public xdispatch::sourcetype { 31 | 32 | static TestTypeBlocks* instance; 33 | TestTypeBlocks() : xdispatch::sourcetype() { 34 | instance = this; 35 | } 36 | 37 | void signalFinished(const xdispatch::any& v){ 38 | ready(v); 39 | } 40 | }; 41 | 42 | TestTypeBlocks* TestTypeBlocks::instance = NULL; 43 | 44 | extern "C" void cxx_dispatch_source_blocks() { 45 | MU_BEGIN_TEST(cxx_dispatch_source_blocks); 46 | 47 | xdispatch::source src(new TestTypeBlocks); 48 | MU_ASSERT_NULL( src.native() ); 49 | src.target_queue(xdispatch::main_queue()); 50 | src.handler(^{ 51 | MU_ASSERT_TRUE(xdispatch::source::data() == "any working"); 52 | MU_PASS(""); 53 | }); 54 | 55 | src.resume(); 56 | 57 | TestTypeBlocks::instance->signalFinished(std::string("any working")); 58 | xdispatch::exec(); 59 | 60 | MU_END_TEST 61 | } 62 | 63 | -------------------------------------------------------------------------------- /tests/cxx_dispatch_source_lambda.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * cxx_dispatch_source_lambda.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "tests.h" 29 | 30 | 31 | struct TestTypeLambda : public xdispatch::sourcetype { 32 | 33 | static TestTypeLambda* instance; 34 | TestTypeLambda() : xdispatch::sourcetype() { 35 | instance = this; 36 | } 37 | 38 | void signalFinished(const xdispatch::any& v){ 39 | ready(v); 40 | } 41 | }; 42 | 43 | TestTypeLambda* TestTypeLambda::instance = NULL; 44 | 45 | extern "C" void cxx_dispatch_source_lambda() { 46 | MU_BEGIN_TEST(cxx_dispatch_source_lambda); 47 | 48 | xdispatch::source src(new TestTypeLambda); 49 | MU_ASSERT_NULL( src.native() ); 50 | src.target_queue(xdispatch::main_queue()); 51 | src.handler([=]{ 52 | MU_ASSERT_TRUE(xdispatch::source::data() == "any working"); 53 | MU_PASS(""); 54 | }); 55 | 56 | src.resume(); 57 | 58 | TestTypeLambda::instance->signalFinished(std::string("any working")); 59 | xdispatch::exec(); 60 | 61 | MU_END_TEST 62 | } 63 | 64 | -------------------------------------------------------------------------------- /tests/dispatch_api.c: -------------------------------------------------------------------------------- 1 | /* 2 | * dispatch_api.c 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include "tests.h" 24 | 25 | #include 26 | 27 | /* 28 | A simple test for ensuring that getting the global 29 | queues is actually working 30 | */ 31 | 32 | static void pass(void* dt){ 33 | MU_PASS("Core API is working"); 34 | } 35 | 36 | void dispatch_api() { 37 | dispatch_queue_t q = NULL; 38 | 39 | MU_BEGIN_TEST(dispatch_api); 40 | 41 | q = dispatch_get_main_queue(); 42 | MU_DESC_ASSERT_NOT_NULL_HEX("dispatch_get_main_queue",q); 43 | dispatch_async_f(q, NULL, pass); 44 | 45 | q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0); 46 | MU_DESC_ASSERT_NOT_NULL_HEX("dispatch_get_global_queue", q); 47 | q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW,0); 48 | MU_DESC_ASSERT_NOT_NULL_HEX("dispatch_get_global_queue", q); 49 | q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH,0); 50 | MU_DESC_ASSERT_NOT_NULL_HEX("dispatch_get_global_queue", q); 51 | 52 | dispatch_main(); 53 | 54 | MU_END_TEST; 55 | } 56 | -------------------------------------------------------------------------------- /tests/dispatch_apply.c: -------------------------------------------------------------------------------- 1 | /* 2 | * dispatch_apply.c 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | #include "tests.h" 27 | 28 | /* 29 | A test for dispatching a function using dispatch_apply_f 30 | */ 31 | 32 | static void argumentFunction(void* data, size_t index){ 33 | dispatch_atomic_inc((intptr_t*)data); 34 | } 35 | 36 | void dispatch_apply_function() { 37 | const unsigned int final = 32; 38 | intptr_t* count = calloc(1,sizeof(intptr_t)); 39 | dispatch_queue_t queue; 40 | MU_BEGIN_TEST(dispatch_apply_function); 41 | *count = 0; 42 | 43 | queue = dispatch_get_global_queue(0, 0); 44 | MU_ASSERT_NOT_NULL(queue); 45 | 46 | dispatch_apply_f(final, queue, count, argumentFunction); 47 | 48 | MU_ASSERT_EQUAL(*count, final); 49 | free(count); 50 | 51 | MU_PASS("Looping works"); 52 | MU_END_TEST 53 | } 54 | -------------------------------------------------------------------------------- /tests/dispatch_apply_blocks.c: -------------------------------------------------------------------------------- 1 | /* 2 | * dispatch_apply_blocks.c 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include 24 | 25 | #include "tests.h" 26 | 27 | /* 28 | A test for dispatching a block using dispatch_apply 29 | */ 30 | 31 | void dispatch_apply_blocks() { 32 | __block uintptr_t count = 0; 33 | const unsigned int final = 32; 34 | 35 | MU_BEGIN_TEST(dispatch_apply_blocks); 36 | dispatch_queue_t queue = dispatch_get_global_queue(0, 0); 37 | MU_ASSERT_NOT_NULL(queue); 38 | 39 | dispatch_apply(final, queue, ^(size_t i) { 40 | dispatch_atomic_inc(&count); 41 | }); 42 | 43 | MU_ASSERT_EQUAL(count, final); 44 | 45 | MU_PASS("Looping works for blocks"); 46 | MU_END_TEST; 47 | } 48 | -------------------------------------------------------------------------------- /tests/dispatch_apply_lambda.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * dispatch_apply_lambda.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | #include 23 | 24 | 25 | #include "tests.h" 26 | 27 | /* 28 | A test for dispatching a block using dispatch_apply 29 | */ 30 | 31 | extern "C" void dispatch_apply_lambda() { 32 | uintptr_t* count = new uintptr_t; 33 | *count = 0; 34 | const unsigned int final = 32; 35 | 36 | MU_BEGIN_TEST(dispatch_apply_lambda); 37 | dispatch_queue_t queue = dispatch_get_global_queue(0, 0); 38 | MU_ASSERT_NOT_NULL(queue); 39 | 40 | dispatch_apply(final, queue, [=](size_t i) { 41 | dispatch_atomic_inc(count); 42 | }); 43 | 44 | MU_ASSERT_EQUAL(*count, final); 45 | delete count; 46 | 47 | MU_PASS("Looping works for blocks"); 48 | MU_END_TEST; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /tests/dispatch_debug.c: -------------------------------------------------------------------------------- 1 | /* 2 | * dispatch_debug.c 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "tests.h" 29 | 30 | 31 | void dispatch_testDebug() { 32 | dispatch_queue_t default_q, main_q; 33 | dispatch_group_t g; 34 | MU_BEGIN_TEST(dispatch_testDebug); 35 | MU_MESSAGE("Printing object debugging information:"); 36 | 37 | main_q = dispatch_get_main_queue(); 38 | MU_ASSERT_NOT_NULL(main_q); 39 | dispatch_debug(main_q, "dispatch_queue_t"); 40 | 41 | default_q = dispatch_get_global_queue(0, 0); 42 | MU_ASSERT_NOT_NULL(default_q); 43 | dispatch_debug(default_q, "dispatch_queue_t"); 44 | 45 | g = dispatch_group_create(); 46 | MU_ASSERT_NOT_NULL(g); 47 | dispatch_debug(g, "dispatch_group_t"); 48 | 49 | MU_MESSAGE("Printing done."); 50 | MU_PASS(""); 51 | MU_END_TEST 52 | } 53 | -------------------------------------------------------------------------------- /tests/dispatch_once.c: -------------------------------------------------------------------------------- 1 | /* 2 | * dispatch_once.c 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include "tests.h" 24 | 25 | #include 26 | 27 | /* 28 | A (very) simple test for ensuring the once 29 | methods are properly working. 30 | NOTE: Still lacking a parallel test 31 | */ 32 | 33 | static dispatch_once_t once_obj; 34 | static int once_counter = 0; 35 | 36 | static void increment(void* unused) { 37 | once_counter++; 38 | } 39 | 40 | void test_dispatch_once() { 41 | MU_BEGIN_TEST(test_dispatch_once); 42 | 43 | MU_ASSERT_EQUAL( once_counter, 0 ); 44 | dispatch_once_f( &once_obj, NULL, increment ); 45 | dispatch_once_f( &once_obj, NULL, increment ); 46 | dispatch_once_f( &once_obj, NULL, increment ); 47 | dispatch_once_f( &once_obj, NULL, increment ); 48 | dispatch_once_f( &once_obj, NULL, increment ); 49 | MU_ASSERT_EQUAL( once_counter, 1 ); 50 | 51 | MU_PASS(""); 52 | 53 | MU_END_TEST; 54 | } 55 | -------------------------------------------------------------------------------- /tests/dispatch_plusplus_blocks.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * dispatch_plusplus_blocks.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include 24 | 25 | 26 | #include "tests.h" 27 | 28 | /* 29 | A short test for ensuring that dispatch a block 30 | in C++ is working 31 | */ 32 | 33 | extern "C" void dispatch_plusplus_blocks(void) { 34 | MU_BEGIN_TEST(dispatch_plusplus_blocks); 35 | 36 | dispatch_queue_t q = dispatch_get_main_queue(); 37 | MU_ASSERT_NOT_NULL(q); 38 | 39 | dispatch_async(dispatch_get_main_queue(), ^{ 40 | int i = 0; 41 | i++; 42 | MU_ASSERT_EQUAL(i, 1); 43 | 44 | const char* pass = "Dispatching blocks works"; 45 | MU_PASS(pass); 46 | }); 47 | dispatch_main(); 48 | MU_FAIL("Should never reach this"); 49 | MU_END_TEST 50 | } 51 | -------------------------------------------------------------------------------- /tests/dispatch_semaphore_blocks.c: -------------------------------------------------------------------------------- 1 | /* 2 | * dispatch_semaphore_blocks.c 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "tests.h" 29 | 30 | #define LAPS 10000 31 | 32 | 33 | void dispatch_semaphore_blocks() 34 | { 35 | static size_t total; 36 | dispatch_semaphore_t dsema; 37 | 38 | MU_BEGIN_TEST(dispatch_semaphore_blocks); 39 | 40 | dsema = dispatch_semaphore_create(1); 41 | MU_ASSERT_NOT_NULL(dsema); 42 | 43 | dispatch_apply(LAPS, dispatch_queue_create(0,0), ^(size_t idx) { 44 | dispatch_semaphore_wait(dsema, DISPATCH_TIME_FOREVER); 45 | total++; 46 | dispatch_semaphore_signal(dsema); 47 | }); 48 | 49 | dispatch_release(dsema); 50 | 51 | MU_ASSERT_EQUAL(total, LAPS); 52 | 53 | MU_PASS(""); 54 | MU_END_TEST; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /tests/dispatch_semaphore_lambda.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * dispatch_semaphore_lambda.cpp 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "tests.h" 29 | 30 | #define LAPS 10000 31 | 32 | 33 | extern "C" void dispatch_semaphore_lambda() 34 | { 35 | static size_t total; 36 | dispatch_semaphore_t dsema; 37 | 38 | MU_BEGIN_TEST(dispatch_semaphore_lambda); 39 | 40 | dsema = dispatch_semaphore_create(1); 41 | MU_ASSERT_NOT_NULL(dsema); 42 | 43 | dispatch_apply(LAPS, dispatch_queue_create(0,0), [=](size_t idx) { 44 | dispatch_semaphore_wait(dsema, DISPATCH_TIME_FOREVER); 45 | total++; 46 | dispatch_semaphore_signal(dsema); 47 | }); 48 | 49 | dispatch_release(dsema); 50 | 51 | MU_ASSERT_EQUAL(total, LAPS); 52 | 53 | MU_PASS(""); 54 | MU_END_TEST; 55 | } 56 | -------------------------------------------------------------------------------- /tests/dispatch_simpleFunction.c: -------------------------------------------------------------------------------- 1 | /* 2 | * dispatch_simpleFunction.c 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | #include "tests.h" 27 | 28 | /* 29 | A simple test checking wether the dispatching 30 | of a simple function is correctly processed 31 | */ 32 | 33 | static void work(void *context) 34 | { 35 | MU_PASS("Scheduled function was called"); 36 | } 37 | 38 | void dispatch_simpleFunction(void) { 39 | dispatch_queue_t q; 40 | MU_BEGIN_TEST(dispatch_simpleFunction); 41 | q = dispatch_get_main_queue(); 42 | MU_ASSERT_NOT_NULL(q); 43 | 44 | dispatch_async_f(dispatch_get_main_queue(), NULL, work); 45 | dispatch_main(); 46 | MU_FAIL("Should never reach this"); 47 | MU_END_TEST; 48 | } 49 | -------------------------------------------------------------------------------- /tests/dispatch_sync.c: -------------------------------------------------------------------------------- 1 | /* 2 | * dispatch_sync.c 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include "tests.h" 24 | 25 | #include 26 | 27 | /* 28 | A simple test for ensuring that the sync call really 29 | only returns if the dispatched object was executed 30 | */ 31 | 32 | int number = 0; 33 | 34 | static void work(void *context) 35 | { 36 | number = 4; 37 | } 38 | 39 | void dispatch_test_sync() { 40 | dispatch_queue_t q; 41 | 42 | MU_BEGIN_TEST(dispatch_sync); 43 | 44 | q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); 45 | MU_ASSERT_NOT_NULL(q); 46 | 47 | dispatch_sync_f(q, NULL, work); 48 | MU_ASSERT_EQUAL(number, 4); 49 | 50 | MU_PASS("Queue order can't be completely wrong"); 51 | MU_END_TEST; 52 | } 53 | -------------------------------------------------------------------------------- /tests/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | * main.c 3 | * 4 | * Copyright (c) 2011-2013 MLBA-Team. 5 | * All rights reserved. 6 | * 7 | * @LICENSE_HEADER_START@ 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * @LICENSE_HEADER_END@ 20 | */ 21 | 22 | #include "munit/MUnit.h" 23 | #if DISPATCH_C_SUPPORT 24 | # include "tests.h" 25 | #else 26 | static void register_tests(){} 27 | #endif 28 | #include "cxx_tests.h" 29 | 30 | #if XDISPATCH_QT_SUPPORT 31 | # include "Qt_tests.h" 32 | #else 33 | static void register_qt_tests(){} 34 | #endif 35 | 36 | void print_log(const char* msg) { 37 | printf("%s", msg); 38 | fflush(stdout); 39 | } 40 | 41 | /* 42 | The test program for testing the dispatch 43 | framework. The difficult task in here is 44 | that all functions dispatched can be started 45 | at any time. Thus each test has to run as own 46 | process, end when all functions were executed 47 | an be supervised by the test application 48 | */ 49 | 50 | int main(int argc, char* argv[]) { 51 | int ret = 0; 52 | MU_initFramework( print_log ); 53 | register_tests(); 54 | register_cxx_tests(); 55 | register_qt_tests(); 56 | 57 | ret = MU_main(argc,argv); 58 | 59 | return ret; 60 | } 61 | -------------------------------------------------------------------------------- /tests/main_ios.c: -------------------------------------------------------------------------------- 1 | /* 2 | * main_ios.c 3 | * 4 | * Copyright (c) 2011 MLBA. 5 | * All rights reserved. 6 | * 7 | * @LICENSE_HEADER_START@ 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * @LICENSE_HEADER_END@ 20 | */ 21 | 22 | #include "munit/MUnit.h" 23 | #include "tests.h" 24 | #include "cxx_tests.h" 25 | #include "Qt_tests.h" 26 | 27 | void null_printer(const char* _unused_){ 28 | 29 | } 30 | 31 | /* 32 | The test library for testing the dispatch 33 | framework. See also main.c 34 | */ 35 | 36 | // call this function from within your 37 | // ios program to run all tests. 38 | // Pass a message handler to print all messages 39 | int run_dispatch_tests(int argc, char* argv[], MU_messageHandler handler) { 40 | int ret = 0; 41 | 42 | if( handler == NULL ) 43 | handler = null_printer; 44 | 45 | MU_initFramework( handler ); 46 | 47 | register_tests(); 48 | register_cxx_tests(); 49 | register_qt_tests(); 50 | 51 | ret = MU_main(argc,argv); 52 | 53 | return ret; 54 | } 55 | -------------------------------------------------------------------------------- /tests/munit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # CMakeLists.txt 3 | # 4 | # Copyright (c) 2011-2014 MLBA-Team 5 | # All rights reserved. 6 | # 7 | # @LICENSE_HEADER_START@ 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # @LICENSE_HEADER_END@ 20 | # 21 | 22 | # munit test framework 23 | 24 | # define file groups 25 | file(GLOB_RECURSE MUNIT *.c *.h) 26 | 27 | # grouping 28 | source_group(munit FILES ${MUNIT}) 29 | 30 | # add new target 31 | add_library(munit STATIC ${MUNIT}) 32 | 33 | # link this target with all needed libraries 34 | target_link_libraries(munit) 35 | mz_target_props(munit) 36 | mz_auto_format_c(munit) 37 | -------------------------------------------------------------------------------- /tests/munit/MUnit.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MUnit.h 3 | * 4 | * Copyright (c) 2011-2014 MLBA-Team 5 | * All rights reserved. 6 | * 7 | * @LICENSE_HEADER_START@ 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * @LICENSE_HEADER_END@ 20 | */ 21 | 22 | #ifndef MUNIT_H_ 23 | #define MUNIT_H_ 24 | 25 | /** 26 | The core header. Include this header in any file 27 | you want to include your tests in. 28 | */ 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | #include "MUnit_assert.h" 35 | #include "MUnit_runner.h" 36 | #include "MUnit_tools.h" 37 | 38 | #ifdef __cplusplus 39 | } 40 | 41 | # include "MUnit_cxx.h" 42 | #endif // ifdef __cplusplus 43 | 44 | #endif /* MUNIT_H_ */ -------------------------------------------------------------------------------- /tests/munit/list.c: -------------------------------------------------------------------------------- 1 | /* 2 | * list.c 3 | * 4 | * Copyright (c) 2011-2014 MLBA-Team 5 | * All rights reserved. 6 | * 7 | * @LICENSE_HEADER_START@ 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * @LICENSE_HEADER_END@ 20 | */ 21 | 22 | #include 23 | 24 | #include "list.h" 25 | 26 | item_t * createList() 27 | { 28 | item_t *t = malloc( sizeof( item_t ) ); 29 | 30 | t->data = NULL; 31 | t->next = NULL; 32 | return t; 33 | } 34 | 35 | 36 | int append( 37 | item_t *lst, 38 | void *data 39 | ) 40 | { 41 | item_t *neu, *last; 42 | 43 | last = lst; 44 | 45 | while( last->next != NULL ) 46 | last = last->next; 47 | 48 | neu = malloc( sizeof( item_t ) ); 49 | 50 | if( neu == NULL ) 51 | return -1; 52 | 53 | last->next = neu; 54 | neu->data = data; 55 | neu->next = NULL; 56 | return 0; 57 | } /* append */ 58 | 59 | 60 | void destroyList( 61 | item_t *lst 62 | ) 63 | { 64 | if( lst->next != NULL ) 65 | destroyList( lst->next ); 66 | 67 | free( lst ); 68 | } -------------------------------------------------------------------------------- /tests/munit/list.h: -------------------------------------------------------------------------------- 1 | /* 2 | * list.h 3 | * 4 | * Copyright (c) 2011-2014 MLBA-Team 5 | * All rights reserved. 6 | * 7 | * @LICENSE_HEADER_START@ 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * @LICENSE_HEADER_END@ 20 | */ 21 | 22 | #ifndef LIST_H_ 23 | #define LIST_H_ 24 | 25 | typedef struct s_item_t 26 | { 27 | struct s_item_t *next; 28 | void *data; 29 | } item_t; 30 | 31 | item_t * 32 | createList(); 33 | 34 | void 35 | destroyList( 36 | item_t *lst 37 | ); 38 | 39 | int 40 | append( 41 | item_t *lst, 42 | void *data 43 | ); 44 | 45 | #endif /* LIST_H_ */ -------------------------------------------------------------------------------- /tests/munit/private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * private.h 3 | * 4 | * Copyright (c) 2011-2014 MLBA-Team 5 | * All rights reserved. 6 | * 7 | * @LICENSE_HEADER_START@ 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * @LICENSE_HEADER_END@ 20 | */ 21 | 22 | #ifndef PRIVATE_H_ 23 | #define PRIVATE_H_ 24 | 25 | #include "MUnit_tools.h" 26 | #include "MUnit_assert.h" 27 | #include "MUnit_runner.h" 28 | 29 | typedef struct 30 | { 31 | mu_test_func function; 32 | const char *name; 33 | } mu_test_t; 34 | 35 | extern char verbose; 36 | 37 | #include "typedefs.h" 38 | 39 | #endif /* PRIVATE_H_ */ -------------------------------------------------------------------------------- /tests/munit/tools.c: -------------------------------------------------------------------------------- 1 | /* 2 | * tools.c 3 | * 4 | * Copyright (c) 2011-2014 MLBA-Team 5 | * All rights reserved. 6 | * 7 | * @LICENSE_HEADER_START@ 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * @LICENSE_HEADER_END@ 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "private.h" 27 | 28 | item_t *suite; 29 | MU_messageHandler msg_handler; 30 | 31 | void _begin_test( 32 | const char *name 33 | ) 34 | { 35 | #ifndef _WIN32 36 | pid_t pid = getpid(); 37 | #else 38 | int pid = GetCurrentProcessId(); 39 | #endif 40 | 41 | if( verbose ) 42 | printf( "[%i] Running test '%s'...\n", pid, name ); 43 | else 44 | printf( "Running test '%s'...", name ); 45 | 46 | fflush( stdout ); 47 | } 48 | 49 | 50 | void _register_suite( 51 | mu_test_func function, 52 | const char *name 53 | ) 54 | { 55 | mu_test_t *t = malloc( sizeof( mu_test_t ) ); 56 | 57 | t->function = function; 58 | t->name = name; 59 | append( suite, (void *)t ); 60 | } -------------------------------------------------------------------------------- /tests/munit/typedefs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * typedefs.h 3 | * 4 | * Copyright (c) 2011-2014 MLBA-Team 5 | * All rights reserved. 6 | * 7 | * @LICENSE_HEADER_START@ 8 | * Licensed under the Apache License, Version 2.0 (the "License"); 9 | * you may not use this file except in compliance with the License. 10 | * You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * @LICENSE_HEADER_END@ 20 | */ 21 | 22 | #ifndef TYPEDEFS_H_ 23 | #define TYPEDEFS_H_ 24 | 25 | // #ifndef __cplusplus 26 | // # ifndef bool 27 | // # define bool char 28 | // # define true 1 29 | // # define false 0 30 | // # endif 31 | // #endif 32 | 33 | #endif /* TYPEDEFS_H_ */ -------------------------------------------------------------------------------- /tests/posix_api.c: -------------------------------------------------------------------------------- 1 | /* 2 | * posix_api.c 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | 24 | #include "tests.h" 25 | 26 | 27 | /* 28 | Test ensuring the proper functionality of the posix api on this platform 29 | */ 30 | 31 | 32 | 33 | void posix_api(){ 34 | MU_BEGIN_TEST(posix_api); 35 | 36 | MU_PASS(""); 37 | 38 | MU_END_TEST; 39 | } 40 | -------------------------------------------------------------------------------- /tests/queue_finalizer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * queue_finalizer.c 3 | * 4 | * Copyright (c) 2008-2009 Apple Inc. 5 | * Copyright (c) 2011-2013 MLBA-Team. 6 | * All rights reserved. 7 | * 8 | * @LICENSE_HEADER_START@ 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * @LICENSE_HEADER_END@ 21 | */ 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #ifdef WIN32 29 | # define WIN32_LEAN_AND_MEAN 1 30 | # include 31 | #else 32 | # include 33 | # include 34 | #endif 35 | 36 | #include "tests.h" 37 | 38 | void *ctxt_magic; 39 | 40 | static void finalizer(void *ctxt) 41 | { 42 | MU_ASSERT_EQUAL(ctxt, ctxt_magic); 43 | MU_PASS("Finalizer run"); 44 | } 45 | 46 | void test_queue_finalizer() { 47 | dispatch_queue_t q; 48 | MU_BEGIN_TEST(test_queue_finalizer); 49 | 50 | #ifndef WIN32 51 | srandom(time(NULL)); 52 | #endif 53 | #ifdef __LP64__ 54 | ctxt_magic = (void*)((uintptr_t)rand() << 32 | rand()); 55 | #else 56 | ctxt_magic = (void*)rand(); 57 | #endif 58 | 59 | q = dispatch_queue_create(NULL, NULL); 60 | MU_ASSERT_NOT_NULL(q); 61 | 62 | dispatch_set_context(q, ctxt_magic); 63 | 64 | dispatch_set_finalizer_f(q, finalizer); 65 | 66 | dispatch_release(q); 67 | 68 | dispatch_main(); 69 | 70 | MU_FAIL("Should never reach this"); 71 | MU_END_TEST 72 | } 73 | -------------------------------------------------------------------------------- /tests/tests.rc: -------------------------------------------------------------------------------- 1 | #include "winuser.h" 2 | 1 RT_MANIFEST xdispatch_tests.manifest 3 | -------------------------------------------------------------------------------- /tests/xdispatch_tests.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /xdispatch.sublime-project: -------------------------------------------------------------------------------- 1 | { 2 | "folders": 3 | [ 4 | { 5 | "file_exclude_patterns": 6 | [ 7 | "*.pyc" 8 | ], 9 | "folder_exclude_patterns": 10 | [ 11 | "build/clang-*", 12 | ".git" 13 | ], 14 | "follow_symlinks": true, 15 | "path": "." 16 | } 17 | ] 18 | } 19 | --------------------------------------------------------------------------------