Blocks For Mac Os X

Blocks are a non-standard extension added by Apple Inc. to Clang's implementations of the C, C++, and Objective-C programming languages that uses a lambda expression-like syntax to create closures within these languages. Blocks are supported for programs developed for Mac OS X 10.6+ and iOS 4.0+,[1] although third-party runtimes allow use on Mac OS X 10.5 and iOS 2.2+[2] and non-Apple systems.

Apple designed blocks with the explicit goal of making it easier to write programs for the Grand Central Dispatch threading architecture,[3][4] although it is independent of that architecture and can be used in much the same way as closures in other languages. Apple has implemented blocks both in their own branch of the GNU Compiler Collection[1] and in the upstream ClangLLVM compiler front end. Language runtime library support for blocks is also available as part of the LLVM project. The Khronos group uses blocks syntax to enqueue kernels from within kernels as of version 2.0 of OpenCL.[5]

Like function definitions, blocks can take arguments, and declare their own variables internally. Unlike ordinary C function definitions, their value can capture state from their surrounding context. A block definition produces an opaque value which contains both a reference to the code within the block and a snapshot of the current state of local stack variables at the time of its definition. The block may be later invoked in the same manner as a function pointer. The block may be assigned to variables, passed to functions, and otherwise treated like a normal function pointer, although the application programmer (or the API) must mark the block with a special operator (Block_copy) if it's to be used outside the scope in which it was defined.

Given a block value, the code within the block can be executed at any later time by calling it, using the same syntax that would be used for calling a function.

Examples[edit]

A simple example capturing mutable state in the surrounding scope is an integer range iterator:[6]

If you are using Mac OS X v10.8 or earlier, Use the 'Yamaha USB Audio Driver'. When using the above products, even if the USB Audio Driver is not installed, a class compliant driver (OS standard driver) is automatically applied when the product is connected to the computer with a USB cable. Gem Blocks 1.0 for Mac can be downloaded from our website for free. The software is categorized as Games. Gem Blocks was developed to work on Mac OS X 10.6.0 or later. This Mac download was scanned by our built-in antivirus and was rated as safe. The most popular version among the.

Compile and execute[edit]

The blocks runtime is not part of the C library(s) linked by default on some systems. If this is the case, it is required to explicitly link to this library:

The runtime is a part of clang's runtime, but is sometimes not installed with the clang package. A standalone runtime extracted from compiler-rt is available.[7]

Relation to GCC nested functions[edit]

Blocks bear a superficial resemblance to GCC's extension of C to support lexically scopednested functions.[8] However, GCC's nested functions, unlike blocks, must not be called after the containing scope has exited, as that would result in undefined behavior.

GCC-style nested functions currently use dynamic creation of executable thunks on most architectures when taking the address of the nested function. On most architectures (including X86), these thunks are created on the stack, which requires marking the stack executable. Executable stacks are generally considered to be a potential security hole. Blocks do not require the use of executable thunks, so they do not share this weakness. On the other hand, blocks introduces a completely new type for the pointer, while pointers to nested functions in GCC are regular function pointers and can be used directly with existing code.

See also[edit]

  • C++11 (includes 'lambda expressions')

References[edit]

  1. ^ ab'Blocks Programming Topics'. Apple Developer. Apple Inc. Retrieved 2011-03-08.
  2. ^https://code.google.com/p/plblocks/
  3. ^'Grand Central Dispatch'(PDF) (technology brief). Apple. 2009-09-03. Archived from the original(PDF) on 2009-09-20. Retrieved June 9, 2009.
  4. ^Siracusa, John (September 1, 2009). 'Mac OS X 10.6 Snow Leopard: the Ars Technica review: Blocks'. Ars Technica.
  5. ^Munshi, Aaftab, ed. (2013-07-13). 'The OpenCL C Specification. Version 2.0. Document Revision 11'(PDF). Khronos OpenCL Working Group. p. 173. Archived from the original(PDF) on 2013-11-05. Retrieved 2013-07-23.
  6. ^Bengtsson, Joachim. 'Programming with C Blocks on Apple Devices'. Archived from the original on 2017-11-15. Retrieved 2009-09-17.
  7. ^'mackyle/blocksruntime: standalone blocks runtime'. Retrieved 15 January 2020.
  8. ^'Nested Functions: Using the GNU Compiler Collection (GCC)'.

External links[edit]

  • 'Clang Language Extensions: Blocks'. LLVM Project. Retrieved 2013-01-20.
  • ''compiler-rt' Runtime Library'. LLVM Project. Retrieved 2013-01-20.
Retrieved from 'https://en.wikipedia.org/w/index.php?title=Blocks_(C_language_extension)&oldid=958069900'
Grand Central Dispatch
Developer(s)Apple Inc.
Operating systemMac OS X 10.6 (2009) and later, iOS 4.0 and later,[1] watchOS, tvOS, FreeBSD
TypeSystem Utility
LicenseApache 2.0
Websitehttps://apple.github.io/swift-corelibs-libdispatch/

Grand Central Dispatch (GCD or libdispatch), is a technology developed by Apple Inc. to optimize application support for systems with multi-core processors and other symmetric multiprocessing systems.[2] It is an implementation of task parallelism based on the thread pool pattern. The fundamental idea is to move the management of the thread pool out of the hands of the developer, and closer to the operating system. The developer injects 'work packages' into the pool oblivious of the pool's architecture. This model improves simplicity, portability and performance.

GCD was first released with Mac OS X 10.6, and is also available with iOS 4 and above. The name 'Grand Central Dispatch' is a reference to Grand Central Terminal.[citation needed]

The source code for the library that provides the implementation of GCD's services, libdispatch, was released by Apple under the Apache License on September 10, 2009.[3] It has been ported[4] to the FreeBSD 8.1+,[5]MidnightBSD 0.3+, [6] Linux, and Solaris.[7][8] Attempts in 2011 to make libdispatch work on Windows were not merged into upstream.[9][10] Apple has its own port of libdispatch.dll for Windows shipped with Safari and iTunes, but no SDK is provided.

BitTorrentBitTorrent’s official torrent client is an ideal torrenting software for Mac. Vuze for mac sierra. Best Torrent Client For MAC (macOS Catalina Compatible) 1. Overall, BitTorrent is an ideal torrent program for macOS Catalina.2. This Mac torrent client offers automatic bandwidth management, and you can even set the download/upload speed limits as per your preference.BitTorrent is completely free to use, but you can upgrade to the Pro version of BitTorrent to unlock features like protection from viruses & malware, ability to watch your torrents without waiting and remove annoying Ads from the program.Lastly, BitTorrent is a light software, and it doesn’t consume much system resources for its proper functioning. UTorrentuTorrent is another feature-rich Mac torrent client, and it’s also a perfect alternative to BitTorrent.The UI and features of uTorrent are mostly similar to that of BitTorrent.

Since around 2017, the original libdispatch repository hosted by Nick Hutchinson[11] was deprecated in favor of a version that is part of the Swift core library created in June 2016. The new version supports more platforms, notably including Windows.

Design[edit]

GCD works by allowing specific tasks in a program that can be run in parallel to be queued up for execution and, depending on availability of processing resources, scheduling them to execute on any of the available processor cores[12][13] (referred to as 'routing' by Apple).[14]

A task can be expressed either as a function or as a 'block.'[15] Blocks are an extension to the syntax of C, C++, and Objective-C programming languages that encapsulate code and data into a single object in a way similar to a closure.[12] GCD can still be used in environments where blocks are not available.[16]

Grand Central Dispatch still uses threads at the low level but abstracts them away from the programmer, who will not need to be concerned with as many details. Tasks in GCD are lightweight to create and queue; Apple states that 15 instructions are required to queue up a work unit in GCD, while creating a traditional thread could easily require several hundred instructions.[12]

A task in Grand Central Dispatch can be used either to create a work item that is placed in a queue or assign it to an event source. If a task is assigned to an event source, then a work unit is made from the block or function when the event triggers, and the work unit is placed in an appropriate queue. This is described by Apple as more efficient than creating a thread whose sole purpose is to wait on a single event triggering.

Features[edit]

The dispatch framework declares several data types and functions to create and manipulate them:

  • Dispatch Queues are objects that maintain a queue of tasks, either anonymous code blocks or functions, and execute these tasks in their turn. The library automatically creates several queues with different priority levels that execute several tasks concurrently, selecting the optimal number of tasks to run based on the operating environment. A client to the library may also create any number of serial queues, which execute tasks in the order they are submitted, one at a time.[13] Because a serial queue can only run one task at a time, each task submitted to the queue is critical with regard to the other tasks on the queue, and thus a serial queue can be used instead of a lock on a contended resource.
  • Dispatch Sources are objects that allow the client to register blocks or functions to execute asynchronously upon system events, such as a socket or file descriptor being ready for reading or writing, or a POSIX signal.
  • Dispatch Groups are objects that allow several tasks to be grouped for later joining. Tasks can be added to a queue as a member of a group, and then the client can use the group object to wait until all of the tasks in that group have completed.
  • Dispatch Semaphores are objects that allow a client to permit only a certain number of tasks to execute concurrently.

Libdispatch comes with its own object model, OS Object, that is partially compatible with the Objective-C model. As a result, its objects can be bridged toll-free to ObjC objects.[17]

Examples[edit]

Mac Os X 10.7 Download Free

Two examples that demonstrate the use of Grand Central Dispatch can be found in John Siracusa's Ars Technica Snow Leopard review.[18] Initially, a document-based application has a method called analyzeDocument which may do something like count the number of words and paragraphs in the document. Normally, this would be a quick process, and may be executed in the main thread without the user noticing a delay between pressing a button and the results showing.

If the document is large and analysis takes a long time to execute then the main thread will wait for the function to finish. If it takes long enough, the user will notice, and the application may even 'beachball'. The solution can be seen here:

Here, the call to [myDoc analyze] is placed inside a Block, which is then placed on one of the global concurrent queues. After it has finished running [myDoc analyze], a new block is placed on the main queue (on which the main thread of the application runs), which updates the GUI (This is necessary because the GUI can only be updated by the main thread). By making these two small changes, the developer has avoided a potential stall of the application as seen by the user, and allowed their application to make better use of hardware resources.

Block Usb Mac Os X

The second example is that of parallelising a for loop:

This code runs the do_work function count times, assigning the ith result to the ith element in the array results, and then calls summarize on array once the loop has ended. Unfortunately the work is computed sequentially, where it may not need to be. Assuming that do_work doesn't rely on the results of any of the other calls made to it, there is no reason why these calls cannot be made concurrently. This is how this would be done in GCD:

Aug 04, 2017  Download Now Mac OS High Sierra VMware Image; #Step 2: Extract & run the downloaded files. After download, the files, extract them in a folder. Extract Files. Now open Unlocker208 and open ” win-install” and Run as administrator. Unlocker208 #Step 3: Create a New Virtual Machine in VMware. Mac os on vmware.

Here, dispatch_apply runs the block passed to it, count times, placing each invocation on a global queue, and passing each block invocation a different number from 0 to count-1. This will allow the OS to spread out the work as it sees fit, choosing the optimal number of threads to run on for the current hardware and system load. dispatch_apply does not return until all the blocks it places on the given queue have completed execution, so that it can be guaranteed that all the work inside the original loop has completed before calling summarize.

Programmers can create their own serial queues for tasks which they know must run serially but which may be executed on a separate thread. A new queue would be created like so:

Care must be taken to avoid a dispatched block on a queue synchronously placing another block on the same queue as this is guaranteed to deadlock. Such code might do the following:

Applications[edit]

GCD is used throughout macOS (beginning with 10.6 Snow Leopard), and Apple has encouraged its adoption by macOS application developers. FreeBSD developer Robert Watson announced the first adaptation of a major open source application, the Apache HTTP Server, to use GCD via the Apache GCD MPM (Multi-Processing Module) on May 11, 2010, in order to illustrate the programming model and how to integrate GCD into existing, large-scale multi-threaded, applications. His announcement observed that the GCD MPM had one third to half the number of lines as other threaded MPMs.[19][20]

Internals[edit]

Blocks for mac os x 10 13 download

GCD is implemented by libdispatch, with support from pthreads non-POSIX extensions developed by Apple. Apple has changed the interface since its inception (in OS X 10.5) through the official launch of GCD (10.6), Mountain Lion (10.8) and recently Mavericks (10.9). The latest changes involve making the code supporting pthreads, both in user mode and kernel, private (with kernel pthread support reduced to shims only, and the actual workqueue implementation moved to a separate kernel extension).[21]

Block Size Mac Os X

One other systems, libdispatch implements its own workqueue using the system's own event facilities (epoll, kevent, or Windows NT). On macOS, kevent is used with the kernel workqueue.

See also[edit]

  • Threading Building Blocks (TBB)

References[edit]

Block Contact Mac Os X

  1. ^'Grand Central Dispatch (GCD) Reference'. Apple Inc.
  2. ^Apple Previews Mac OS X Snow Leopard to DevelopersArchived March 19, 2012, at WebCite, June 9, 2008.
  3. ^http://libdispatch.macosforge.org/
  4. ^GCD libdispatch w/Blocks support working on FreeBSD
  5. ^FreeBSD Quarterly Status Report
  6. ^libdispatch
  7. ^libdispatch mailing list: 'Porting status Linux' April 10, 2011
  8. ^libdispatch mailing list: 'Porting status Solaris x86/64' April 10, 2011
  9. ^libdispatch mailing list: 'libdispatch for Win32' April 22, 2011
  10. ^libdispatch mailing list: 'Updates regarding the status of libdispatch on Windows' May 5, 2011
  11. ^Hutchinson, Nicholas (January 10, 2020). 'libdispatch'. GitHub. Retrieved January 15, 2020.
  12. ^ abc'Apple Technical Brief on Grand Central Dispatch'(PDF). Archived from the original on September 20, 2009. Retrieved September 12, 2009.CS1 maint: BOT: original-url status unknown (link)
  13. ^ abGagne, Abraham Silberschatz, Peter Baer Galvin, Greg (2013). Operating system concepts (9th ed.). Hoboken, N.J.: Wiley. pp. 182–183. ISBN9781118063330.
  14. ^'WWDC 2008: New in Mac OS X Snow Leopard'. Archived from the original on October 17, 2008. Retrieved June 18, 2008.
  15. ^'Grand Central Dispatch (GCD) Reference'. Retrieved September 13, 2009.
  16. ^https://wiki.freebsd.org/GCD#The_same_program.2C_without_C_Blocks
  17. ^Bugaev, Sergey. 'Mach-O linking and loading tricks'. Darling development blog. Retrieved January 15, 2020.
  18. ^Mac OS X 10.6 Snow Leopard: the Ars Technica review (accessed September 2, 2009)
  19. ^libdispatch-dev GCD MPM for Apache (accessed May 14, 2010)
  20. ^apache-libdispatch (accessed May 14, 2010)
  21. ^Levin, Jonathan (February 15, 2014). 'GCD Internals: The undocumented side of the Grand Central Dispatcher'. Retrieved March 17, 2014.

External links[edit]

Mac Os X 10.11 Download Free

Retrieved from 'https://en.wikipedia.org/w/index.php?title=Grand_Central_Dispatch&oldid=957063986'