libdispatch

libDispatch serving main queue without dispatch_main on Android

早过忘川 提交于 2020-01-13 05:00:32
问题 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 problem is coming... I am able to run tasks in the concurrent queues but not on main queue. Since this requires dispatch_main() to be called which we cannot do on here as Java thread will be blocked in that case. So, is it possible to run the Java UI on

How to use GLFW to poll for events in a libdispatch block?

♀尐吖头ヾ 提交于 2020-01-04 16:58:40
问题 Following up on the answer to How to use GLUT with libdispatch?, I'm now using GLFW instead — The following code sets up a window, sets up a timer to poll for events, and, over time, enqueues render updates: #include <dispatch/dispatch.h> #include <GL/glfw.h> float t=0; int main(void) { dispatch_async(dispatch_get_main_queue(), ^{ glfwInit(); glfwDisable(GLFW_AUTO_POLL_EVENTS); glfwOpenWindow(320,200,8,8,8,8,8,0,GLFW_WINDOW); }); // Periodically process window events --- this isn't working.

How to use GLFW to poll for events in a libdispatch block?

老子叫甜甜 提交于 2020-01-04 16:57:30
问题 Following up on the answer to How to use GLUT with libdispatch?, I'm now using GLFW instead — The following code sets up a window, sets up a timer to poll for events, and, over time, enqueues render updates: #include <dispatch/dispatch.h> #include <GL/glfw.h> float t=0; int main(void) { dispatch_async(dispatch_get_main_queue(), ^{ glfwInit(); glfwDisable(GLFW_AUTO_POLL_EVENTS); glfwOpenWindow(320,200,8,8,8,8,8,0,GLFW_WINDOW); }); // Periodically process window events --- this isn't working.

How to use GLUT with libdispatch?

做~自己de王妃 提交于 2020-01-04 11:00:21
问题 Both GLUT and libdispatch have their own event-handling loops, which are invoked with functions that never return: glutMainLoop(); and dispatch_main(); , respectively. I've tried: dispatch_queue_t q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_async(q, ^{ glutMainLoop(); }); dispatch_main(); ...and the window displays, but does not respond to any events or redraw after the initial call to the function specified with glutDisplayFunc() . How can I get GLUT and

Whither dispatch_once in Swift 3?

て烟熏妆下的殇ゞ 提交于 2019-12-17 04:56:10
问题 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 things like singleton creation and one-time setup don't get executed more than once (even in a multithreaded environment)... and dispatch_once is nowhere to be found in the new Dispatch module? static var token: dispatch_once_t = 0 func whatDoYouHear

Is the following a safe use of dispatch_set_target_queue()?

℡╲_俬逩灬. 提交于 2019-12-16 18:07:08
问题 What I want to do is create an indirect queue targeting the main queue. dispatch_queue_t myQueue = dispatch_queue_create("com.mydomain.my-main-queue", NULL); dispatch_set_target_queue(myQueue, dispatch_get_main_queue()); My ultimate goal is to use the queue as the underlyingQueue property of an NSOperationQueue, because Apple's documentation clearly states not to use dispatch_get_main_queue(). Though using an indirect queue it technically is following the documentation. The reason for all

Cancelling dispatch_io_read

微笑、不失礼 提交于 2019-12-12 02:27:03
问题 I'm parsing a very large CSV file using GCD functions (please see code below). If I encounter an error I'd like to cancel dispatch_io_read . Is there a way to do that? dispatch_io_read(channel, 0, Int.max, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)) { (done, data, error) in guard error == 0 else { print("Read Error: \(error)") return } if done { lineBuffer.dealloc(bufferSize) } dispatch_data_apply(data) { (region, offset, buffer, size) -> Bool in print(size) let bytes =

libDispatch serving RunOnMainQueueDelayed from Java

别等时光非礼了梦想. 提交于 2019-12-11 12:59:56
问题 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). I am scheduling some tasks with delay on the MainQueue using the function RunOnMainQueueDelayed. To run the main queue tasks I am running a timer of 15ms on java side and whenever timer expires I run a JNI call which will run the function _dispatch_main_queue_callback_4CF on native side so tht the tasks on the mainqueue gets

Compiling libDispatch (GCD) for Android

人走茶凉 提交于 2019-12-07 20:42:43
问题 I'm trying to compile libdispatch for linux on Android. However I could not find any instructions for Android in the project files. I can see there are several StackOverflow questions about using libdispatch, but the information is rather thin. Has anyone successfully compiled libdispatch for Android using NDK? 回答1: I haven't personally tried compiling libdispatch for Android, but I have built many other libraries. It looks like building libdispatch should be quite easy, as there is already

Grand Central Dispatch without blocks

做~自己de王妃 提交于 2019-12-04 21:53:55
Is it possible to use GCD without blocks? Is there a way to use GCD using _f variant as mikeash says in his post . I searched around and there is no proof for either sides. is it possible or impossible. If its doable please give an example. /Selvin Of course it is possible! By _f variants Mike just mean set of GCD functions with _f suffix. They are alternatives for usual GCD functions but can accept a user defined function as a parameter instead of blocks. There are plenty of them: dispatch_async_f dispatch_sync_f dispatch_after_f dispatch_apply_f dispatch_group_async_f dispatch_group_notify_f