本文整理汇总了C++中dispatch_get_global_queue函数的典型用法代码示例。如果您正苦于以下问题:C++ dispatch_get_global_queue函数的具体用法?C++ dispatch_get_global_queue怎么用?C++ dispatch_get_global_queue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dispatch_get_global_queue函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Qt_dispatch_source_signal_lambda
extern "C" void Qt_dispatch_source_signal_lambda(){
char argv[] = "test";
int argc = 1;
QDispatchApplication app(argc, (char**)&argv);
MU_BEGIN_TEST(Qt_dispatch_source_signal_lambda);
EmitterLambda object;
// configure the source
QDispatchSource src(new QDispatchSourceTypeSignal(&object, SIGNAL(ready())));
src.setTargetQueue(QDispatch::globalQueue(QDispatch::LOW));
src.setHandler([=]{
MU_MESSAGE("Signal was emitted");
if(QDispatch::currentQueue().native() == dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0))
MU_MESSAGE("Executed on low global queue");
else if(QDispatch::currentQueue().native() == dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0))
MU_MESSAGE("Executed on default global queue");
else if(QDispatch::currentQueue().native() == dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0))
MU_MESSAGE("Executed on high global queue");
else if(QDispatch::currentQueue().native() == dispatch_get_main_queue())
MU_MESSAGE("Executed on main queue");
MU_ASSERT_EQUAL_HEX(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), QDispatch::currentQueue().native());
MU_PASS("");
});
// trigger the signal
object.notify();
app.exec();
MU_END_TEST;
}
开发者ID:digiverse,项目名称:cool,代码行数:32,代码来源:Qt_dispatch_source_signal_lambda.cpp
示例2: test_io_close
static void
test_io_close(int with_timer, bool from_path)
{
#define chunks 4
#define READSIZE (512*1024)
unsigned int i;
const char *path = LARGE_FILE;
int fd = open(path, O_RDONLY);
if (fd == -1) {
if (errno == ENOENT) {
test_skip("Large file not found");
return;
}
test_errno("open", errno, 0);
test_stop();
}
#ifdef F_GLOBAL_NOCACHE
if (fcntl(fd, F_GLOBAL_NOCACHE, 1) == -1) {
test_errno("fcntl F_GLOBAL_NOCACHE", errno, 0);
test_stop();
}
#endif
struct stat sb;
if (fstat(fd, &sb)) {
test_errno("fstat", errno, 0);
test_stop();
}
const size_t size = (size_t)sb.st_size / chunks;
const int expected_error = with_timer? ECANCELED : 0;
dispatch_source_t t = NULL;
dispatch_group_t g = dispatch_group_create();
dispatch_group_enter(g);
void (^cleanup_handler)(int error) = ^(int error) {
test_errno("create error", error, 0);
dispatch_group_leave(g);
close(fd);
};
dispatch_io_t io;
if (!from_path) {
io = dispatch_io_create(DISPATCH_IO_RANDOM, fd,
dispatch_get_global_queue(0, 0), cleanup_handler);
} else {
#if DISPATCHTEST_IO_PATH
io = dispatch_io_create_with_path(DISPATCH_IO_RANDOM, path, O_RDONLY, 0,
dispatch_get_global_queue(0, 0), cleanup_handler);
#endif
}
dispatch_io_set_high_water(io, READSIZE);
if (with_timer == 1) {
dispatch_io_set_low_water(io, READSIZE);
dispatch_io_set_interval(io, 2 * NSEC_PER_SEC,
DISPATCH_IO_STRICT_INTERVAL);
} else if (with_timer == 2) {
t = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,
dispatch_get_global_queue(0,0));
dispatch_retain(io);
dispatch_source_set_event_handler(t, ^{
dispatch_io_close(io, DISPATCH_IO_STOP);
dispatch_source_cancel(t);
});
开发者ID:helje5,项目名称:swift-corelibs-libdispatch,代码行数:60,代码来源:dispatch_io.c
示例3: main
int
main()
{
dispatch_queue_t q[PRIORITIES];
int i;
#if USE_SET_TARGET_QUEUE
test_start("Dispatch Priority (Set Target Queue)");
for(i = 0; i < PRIORITIES; i++) {
q[i] = dispatch_queue_create(labels[i], NULL);
test_ptr_notnull("q[i]", q[i]);
assert(q[i]);
dispatch_set_target_queue(as_do(q[i]), dispatch_get_global_queue(priorities[i], 0));
dispatch_queue_set_width(q[i], DISPATCH_QUEUE_WIDTH_MAX_LOGICAL_CPUS);
}
#else
test_start("Dispatch Priority");
for(i = 0; i < PRIORITIES; i++) {
q[i] = dispatch_get_global_queue(priorities[i], 0);
}
#endif
for(i = 0; i < PRIORITIES; i++) {
submit_work(q[i], &counts[i].count);
}
dispatch_main();
}
开发者ID:DrPizza,项目名称:libdispatch,代码行数:28,代码来源:dispatch_priority.c
示例4: CFSocketFinalize
static void
CFSocketFinalize (CFTypeRef cf)
{
CFSocketRef s = (CFSocketRef)cf;
#if HAVE_LIBDISPATCH
dispatch_queue_t q = dispatch_get_global_queue(
DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_source_cancel(s->_readSource);
dispatch_source_cancel(s->_writeSource);
// Wait for source handlers to complete
// before we proceed to destruction.
dispatch_barrier_sync_f(q, NULL, DummyBarrier);
if (s->_source != NULL)
CFRelease(s->_source);
#endif
if (s->_socket != -1)
{
GSMutexLock (&_kCFSocketObjectsLock);
CFDictionaryRemoveValue(_kCFSocketObjects,
(void*)(uintptr_t) s->_socket);
closesocket (s->_socket);
GSMutexUnlock (&_kCFSocketObjectsLock);
}
if (s->_address)
CFRelease (s->_address);
if (s->_peerAddress)
CFRelease (s->_peerAddress);
}
开发者ID:1053948334,项目名称:myos.frameworks,代码行数:32,代码来源:CFSocket.c
示例5: mrb_queue_concurrent
static mrb_value
mrb_queue_concurrent(mrb_state *mrb, mrb_value self)
{
mrb_value instance;
mrb_sym priority;
long priority_value;
dispatch_queue_t q;
mrb_get_args(mrb, "|n", &priority);
if (priority == mrb_intern_cstr(mrb, "high")) {
priority_value = DISPATCH_QUEUE_PRIORITY_HIGH;
}
else if (priority == mrb_intern_cstr(mrb, "low")) {
priority_value = DISPATCH_QUEUE_PRIORITY_LOW;
}
#ifdef DISPATCH_QUEUE_PRIORITY_BACKGROUND
else if (priority == mrb_intern_cstr(mrb, "background")) {
priority_value = DISPATCH_QUEUE_PRIORITY_BACKGROUND;
}
#endif
else {
priority_value = DISPATCH_QUEUE_PRIORITY_DEFAULT;
}
instance = mrb_queue_create_instance(mrb);
q = dispatch_get_global_queue(priority_value, 0);
return mrb_queue_set_queue(instance, q);
}
开发者ID:dorentus,项目名称:mruby-dispatch,代码行数:30,代码来源:queue.c
示例6: halide_do_par_for
WEAK void halide_do_par_for(void (*f)(int, uint8_t *), int min, int size, uint8_t *closure) {
halide_gcd_job job;
job.f = f;
job.closure = closure;
job.min = min;
dispatch_apply_f(size, dispatch_get_global_queue(0, 0), &job, &halide_do_gcd_task);
}
开发者ID:hirokai,项目名称:Halide,代码行数:7,代码来源:gcd_thread_pool.cpp
示例7: tests
static void tests(void)
{
// CFStringRef messageToUser = CFSTR("OK to sync with world?");
// CFStringRef messageToUser = CFSTR("Allow “Emily‘s iPad to use your iCloud Keychain?");
#if !TARGET_IPHONE_SIMULATOR
#if TARGET_OS_EMBEDDED
CFStringRef our_peer_id = (CFStringRef)MGCopyAnswer(kMGQUserAssignedDeviceName, NULL);
#else
CFStringRef our_peer_id = CFSTR("
|
请发表评论