Questions tagged [libdispatch]

The libdispatch project consists of the user space implementation of the Grand Central Dispatch API.

50 questions
263
votes
6 answers

How do I dispatch_sync, dispatch_async, dispatch_after, etc in Swift 3, Swift 4, and beyond?

I have lots of code in Swift 2.x (or even 1.x) projects that looks like this: // Move to a background thread to do some long running work dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) { let image =…
rickster
  • 124,678
  • 26
  • 272
  • 326
58
votes
7 answers

Whither dispatch_once in Swift 3?

Okay, so I found out about the new Swifty Dispatch API in Xcode 8. I'm having fun using DispatchQueue.main.async, and I've been browsing around the Dispatch module in Xcode to find all the new APIs. But I also use dispatch_once to make sure that…
rickster
  • 124,678
  • 26
  • 272
  • 326
17
votes
5 answers

Could Grand Central Dispatch (`libdispatch`) ever be made available on Windows?

I’m looking into multithreading, and GCD seems like a much better option than manually writing a solution using pthread.h and pthreads-win32. However, although it looks like libdispatch is either working on, or soon going to be working on, most…
15
votes
4 answers

Are blocks and libdispatch available on linux?

I would love to try out grand central dispatch, but all I have to develop on is an Ubuntu workstation. Is libdispatch, and the blocks extension to c/obj-c etc... available on linux? If so, how do I get them?
mummey
  • 253
  • 2
  • 6
10
votes
2 answers

GCD dispatch_async memory leak?

The following code will occupy ~410MB of memory and will not release it again. (The version using dispatch_sync instead of dispatch_async will require ~8MB memory) I would expect a spike of high memory usage but it should go down again... Where is…
6
votes
1 answer

Crash in libdispatch _dispatch_semaphore_wait_slow

I sometimes get a crash deep inside libdispatch with the following backtrace stemming from the SecItemCopyMatching function. * thread #1: tid = 0x169ee8, 0x0374c830 libdispatch.dylib`_dispatch_semaphore_wait_slow + 278, queue =…
0xced
  • 25,219
  • 10
  • 103
  • 255
5
votes
1 answer

Swift in Linux: use of unresolved identifier 'dispatch_async'

I compiled libdispatch. This code is working: import Dispatch var lockQueue = dispatch_queue_create("com.test.async", nil); But if I put this code to end file: dispatch_async(lockQueue) { print("test1"); } I got an error: use of unresolved…
zig1375
  • 294
  • 1
  • 12
4
votes
1 answer

Xcode error: unable to find sdk 'macosx.internal' (in target 'libdispatch')

I'm compiling Apple libdispatch. But there was an error Error: unable to find SDK 'macosx.internal' (in target 'libdispatch') Does anyone have prior experience with this error?
Hansu
  • 41
  • 2
4
votes
3 answers

Concurrent programming in OpenCL vs Grand Central Dispatch

With the introduction of OpenCL 2.0, OpenCL seems to have many of the features of Grand Central Dispatch (GCD), such as CLang/Apple style blocks and queues. Looking at their respective feature sets, I am wondering if OpenCL can do everything the…
3
votes
1 answer

Isn't dispatch_semaphore_wait FIFO?

The documentation for dispatch_semaphore_wait says that it "waits in FIFO order for a signal". But it doesn't seem to in this example-- can someone please explain? Example: #include #include dispatch_queue_t q1,…
jlstrecker
  • 4,953
  • 3
  • 46
  • 60
3
votes
0 answers

What exactly is GCD overcommit and is it dangerous

I've been working on some code recently where I want to ensure that certain tasks run sequentially always execute on the same thread. As an experiment to get a feel for how this would work I created my own thread using this example Thread Example My…
dubbeat
  • 7,706
  • 18
  • 70
  • 122
3
votes
1 answer

Type mismatch in Swift GCD overlay

I'd like to use a dispatch IO channel to read some data from a file descriptor. After creating the channel, the next step is to call read, whose declaration is as follows: func read(offset: off_t, length: Int, queue: DispatchQueue,…
ravron
  • 11,014
  • 2
  • 39
  • 66
3
votes
1 answer

Install Swift 3 + libdispatch on Linux with Ansible

I'm struggling to get Swift 3.0 and GCD installed on a Ubuntu 16.04. This should be possible nowadays, right? Below is an Ansible task for downloading Swift 3 from swift.org, cloning, building and installing swift-corelibs-libdispatch from…
samuke
  • 450
  • 1
  • 5
  • 15
3
votes
1 answer

libDispatch serving main queue without dispatch_main on Android

I am using libDispatch (GCD) opensource on Android platform. So, most of the complex time consuming tasks are being done through NDK (where i am using libDispatch). For some calls, I am using dispatch_async(get_main_queue)...This is where the…
3
votes
1 answer

Ubuntu libdispatch

I am trying to port a program that uses GCD (Grand Central Dispatch) from OSX to Ubuntu 11.10. I installed libdispatch but I keep getting the following error: undefined reference to dispatch_main() The strange thing is that dispatch_main() is…
syzygy
  • 1,356
  • 3
  • 16
  • 28
1
2 3 4