当前位置: 首页>>代码示例>>C++>>正文


C++ CFAbsoluteTimeGetCurrent函数代码示例

本文整理汇总了C++中CFAbsoluteTimeGetCurrent函数的典型用法代码示例。如果您正苦于以下问题:C++ CFAbsoluteTimeGetCurrent函数的具体用法?C++ CFAbsoluteTimeGetCurrent怎么用?C++ CFAbsoluteTimeGetCurrent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CFAbsoluteTimeGetCurrent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dispatchUnicodeEvent

static void dispatchUnicodeEvent(char c)
{
    UnicodeReport report;
    static CFAbsoluteTime sDeadline = 0;
    CFAbsoluteTime delta;
    
    bzero(&report, sizeof(report));
    if ( c < 'a' || c > 'z' )
        return;
    
    printf("dispatching unicode event for '%c'\n", c);
    
    pthread_mutex_lock(&gMuxtex);
    
    delta = sDeadline - CFAbsoluteTimeGetCurrent();
    if ( delta > 0 )
        usleep(delta*1000000);
    
    report.usage = c;
    
    OSSwapHostToLittleInt16(report.usage);

    printReport((uint8_t*)&report, sizeof(report), 0);
    IOHIDUserDeviceHandleReport(gDevice, (uint8_t*)&report, sizeof(report));
    
    sDeadline = CFAbsoluteTimeGetCurrent() + kKeyboardInterval;
    
    pthread_mutex_unlock(&gMuxtex);
    
}
开发者ID:aosm,项目名称:IOHIDFamily,代码行数:30,代码来源:IOHIDUserDeviceTest.c

示例2: fseventerCallback

void fseventerCallback(
    ConstFSEventStreamRef streamRef,
    void *clientCallBackInfo,
    size_t numEvents,
    void *eventPaths,
    const FSEventStreamEventFlags eventFlags[],
    const FSEventStreamEventId eventIds[])
{
    (void)streamRef; // unused
    (void)numEvents; // unused
    (void)eventPaths; // unused
    (void)eventFlags; // unused
    (void)eventIds; // unused

    Autobuild::Impl *mPimpl = static_cast<Autobuild::Impl*>(clientCallBackInfo);


    CFAbsoluteTime now = CFAbsoluteTimeGetCurrent();
    
    // Ignore when events are under ignoretime from last executed event
    if(now - mPimpl->last < mPimpl->ignore) {
        return;
    }

    std::cout << "[autobuild] " << mPimpl->command << std::endl; 
    system(mPimpl->command);

    // set the last updated timestamp *after* command
    mPimpl->last = CFAbsoluteTimeGetCurrent();

}
开发者ID:scoopr,项目名称:autobuild,代码行数:31,代码来源:autobuild_osx.cpp

示例3: dispatchKeyboardEvent

static void dispatchKeyboardEvent(char c)
{
    KeyboardInputReport report;
    static CFAbsoluteTime sDeadline = 0;
    CFAbsoluteTime delta;
    
    bzero(&report, sizeof(report));
    if ( c < 'a' || c > 'z' )
        return;
    
    printf("dispatching keyboard event for '%c'\n", c);
    
    pthread_mutex_lock(&gMuxtex);
    
    delta = sDeadline - CFAbsoluteTimeGetCurrent();
    if ( delta > 0 )
        usleep(delta*1000000);
    
    report.keys[0] = 4 + c - 97;
    printReport((uint8_t*)&report, sizeof(report), 0);
    IOHIDUserDeviceHandleReport(gDevice, (uint8_t*)&report, sizeof(report));
    
    usleep(kKeyboardInterval*1000000);
    
    report.keys[0] = 0;
    printReport((uint8_t*)&report, sizeof(report), 0);
    IOHIDUserDeviceHandleReport(gDevice, (uint8_t*)&report, sizeof(report));
    
    sDeadline = CFAbsoluteTimeGetCurrent() + kKeyboardInterval;
    
    pthread_mutex_unlock(&gMuxtex);
    
}
开发者ID:aosm,项目名称:IOHIDFamily,代码行数:33,代码来源:IOHIDUserDeviceTest.c

示例4: _HttpContextHandleHasBytesAvailable

/* static */ void
_HttpContextHandleHasBytesAvailable(HttpContextRef context) {

	UInt8 buffer[2048];
	
	// Try reading the bytes into the buffer.
	CFIndex bytesRead = CFReadStreamRead(context->_inStream, buffer, sizeof(buffer));
	
	// Reset the timeout.
	CFRunLoopTimerSetNextFireDate(context->_timer, CFAbsoluteTimeGetCurrent() + kTimeOutInSeconds);
	
	// If there wasn't an error (-1) and not end (0), process the data.
	if (bytesRead > 0) {
		
		// Add the bytes of data to the receive buffer.
		CFDataAppendBytes(context->_rcvdBytes, buffer, bytesRead);

		// Parse recieved data
        int result = HTTPParseRequest(context);      
        
        if ( result == 1 ) {
            // HTTP message is fully loaded, process it
            HTTPProcessMessage(context);
			
			// Reset the timeout.
			CFRunLoopTimerSetNextFireDate(context->_timer, CFAbsoluteTimeGetCurrent() + kTimeOutInSeconds);
        }
        
        // If the ouput stream can write, try sending the bytes.
		if (result != 0 && CFWriteStreamCanAcceptBytes(context->_outStream))
			_HttpContextHandleCanAcceptBytes(context);
	}
}
开发者ID:DoktahWorm,项目名称:rhodes,代码行数:33,代码来源:HttpContext.c

示例5: check_date_comparison

bool check_date_comparison ()
{
   CFDateRef           date1, date2;
   
   // Standard Core Foundation comparison result.
   CFComparisonResult result;
   
   CFShow(CFSTR("Checking date comparison functions:"));
   
   // Create two CFDates from absolute time.
   date1 = CFDateCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent());
   date2 = CFDateCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent());
   
   // Pass NULL for the context param.
   result = CFDateCompare(date1, date2, NULL);
   
   switch (result) {
      case kCFCompareLessThan:
         CFShow(CFSTR("date1 is before date2!\n"));
         break;
      case kCFCompareEqualTo:
         CFShow(CFSTR("date1 is the same as date2!\n"));
         break;
      case kCFCompareGreaterThan:
         CFShow(CFSTR("date1 is after date2!\n"));
         break;
   }
   
   printf("\n");

   return true;
}
开发者ID:AbhinavBansal,项目名称:opencflite,代码行数:32,代码来源:date_test.c

示例6: test_dotproduct

void test_dotproduct() {
	printf("--------------------------------------------------------------------------------\n");
	printf("dot product\n");
	printf("--------------------------------------------------------------------------------\n");
	
	CFAbsoluteTime startTime;
	float *inputOne, *inputTwo, *result, dotProduct;
	int32_t strideOne=1, strideTwo=1;
	uint32_t size = 1024;
	
	int test_count = 100;
	
	// alloc memory
	inputOne = (float*)malloc(size * sizeof(float));
	inputTwo = (float*)malloc(size * sizeof(float));
	result = (float*)malloc(size * sizeof(float));
	
	// initialize two vectors
	for (int i = 0; i < size; i++) {
		inputOne[i] = 1;
		inputTwo[i] = 0.5;
	}
	
	printf("----------------------------------------\n");
	printf("Condition\n");
	// display condition
	printf(" %d-dim vec\n", size);
	printf(" test, %d times\n", test_count);
	
	printf("----------------------------------------\n");
	printf("Result\n");
	// use vDSP
	startTime=CFAbsoluteTimeGetCurrent();
	for (int j = 0; j < test_count; j++) {
		vDSP_dotpr(inputOne, strideOne, inputTwo, strideTwo, &dotProduct, size);
	}
	printf("Accelerate.framework\n");
	printf(" %f msec\n", (CFAbsoluteTimeGetCurrent() - startTime)*1000.0f );
	
	// use CPU
	startTime=CFAbsoluteTimeGetCurrent();
	for (int j = 0; j < test_count; j++) {
		dotProduct = 0;
		for (int i = 0; i < size; i++) {
			dotProduct += inputOne[j] * inputTwo[j];
		}
	}
	printf("Normal\n");
	printf(" %f msec\n", (CFAbsoluteTimeGetCurrent() - startTime)*1000.0f );
	printf("\n");
	
	// release objects
	free(inputOne);
	free(inputTwo);
	free(result);
}
开发者ID:coiled-coil,项目名称:iOS_SDK_Hacks,代码行数:56,代码来源:vdsp_dotproduct.c

示例7: doFftForStripeSize

/*
 * -- Set up a plan for specified FFT type and column stripe size
 * -- time the execution of 'loops' pairs of FFT;
 * -- if elapsed time < current fastest, replace fasted time & stripe size with current
 */
static int doFftForStripeSize(
    FFTParams *params,
    size_t newStripeSize,
    CFAbsoluteTime *fastest,        // IN/OUT
    size_t *fastestStripeSize,      // IN/OUT
    CFAbsoluteTime *slowest,        // IN/OUT
    Verbosity verbosity)
{
    uint32_t fwdFlags = 0;
    uint32_t invFlags = MEF_NormOutput;
    MatrixFFTPlan mfftPlan;
    MFFTReturn mrtn;
    
    mfftSetColumnStripeSize(params->isReal, newStripeSize);
    mrtn = mfftCreatePlan(params->dims, params->n, params->isReal, 0, 0, &mfftPlan);
    if(mrtn) {
        mfftPrintErrInfo("mfftCreatePlan", mrtn);
        return -1;
    }
    
    CFAbsoluteTime startTime, endTime, elapsed;
    
    if(verbosity == V_Noisy) {
        printf("+++++++++ stripeSize %llu\n", (unsigned long long)newStripeSize);
    }
    startTime = CFAbsoluteTimeGetCurrent();
    for(unsigned loop=0; loop<params->loops; loop++) {
        mrtn = mfftExecute(mfftPlan, fwdFlags, true, params->buf, params->buf);
        if(mrtn) {
            mfftPrintErrInfo("mfftExecute(fwd)", mrtn);
            break;
        }
        mrtn = mfftExecute(mfftPlan, invFlags, false, params->buf, params->buf);
        if(mrtn) {
            mfftPrintErrInfo("mfftExecute(inv)", mrtn);
            break;
        }
    }
    endTime = CFAbsoluteTimeGetCurrent();
    elapsed = endTime - startTime;
    if(verbosity == V_Noisy) {
        printf("          elapsed %.2e\n", elapsed);
    }
    if((*fastest == 0.0) ||     // i.e. nothing measured yet
       (*fastest > elapsed)) {
        *fastest = elapsed;
        *fastestStripeSize = newStripeSize;
    }
    if(elapsed > *slowest) {
        *slowest = elapsed;
    }
    mfftFreePlan(mfftPlan);
    return (mrtn == MR_Success) ? 0 : 1;
}
开发者ID:JeffreyEarly,项目名称:GLNumericalModelingKit,代码行数:59,代码来源:mfftAutoConf.cpp

示例8: ASSERT

MessageQueueWaitResult WorkerRunLoop::runInMode(WorkerGlobalScope* context, const ModePredicate& predicate, WaitMode waitMode)
{
    ASSERT(context);
    ASSERT(context->thread().threadID() == currentThread());

#if PLATFORM(GTK) || PLATFORM(WPE)
    GMainContext* mainContext = g_main_context_get_thread_default();
    if (g_main_context_pending(mainContext))
        g_main_context_iteration(mainContext, FALSE);
#endif

    double deadline = MessageQueue<Task>::infiniteTime();

#if USE(CF)
    CFAbsoluteTime nextCFRunLoopTimerFireDate = CFRunLoopGetNextTimerFireDate(CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
    double timeUntilNextCFRunLoopTimerInSeconds = nextCFRunLoopTimerFireDate - CFAbsoluteTimeGetCurrent();
    deadline = currentTime() + std::max(0.0, timeUntilNextCFRunLoopTimerInSeconds);
#endif

    double absoluteTime = 0.0;
    if (waitMode == WaitForMessage) {
        if (predicate.isDefaultMode() && m_sharedTimer->isActive())
            absoluteTime = std::min(deadline, m_sharedTimer->fireTime());
        else
            absoluteTime = deadline;
    }
    MessageQueueWaitResult result;
    auto task = m_messageQueue.waitForMessageFilteredWithTimeout(result, predicate, absoluteTime);

    // If the context is closing, don't execute any further JavaScript tasks (per section 4.1.1 of the Web Workers spec).  However, there may be implementation cleanup tasks in the queue, so keep running through it.

    switch (result) {
    case MessageQueueTerminated:
        break;

    case MessageQueueMessageReceived:
        task->performTask(*this, context);
        break;

    case MessageQueueTimeout:
        if (!context->isClosing())
            m_sharedTimer->fire();
#if USE(CF)
        if (nextCFRunLoopTimerFireDate <= CFAbsoluteTimeGetCurrent())
            CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, /*returnAfterSourceHandled*/ false);
#endif
        break;
    }

    return result;
}
开发者ID:emutavchi,项目名称:WebKitForWayland,代码行数:51,代码来源:WorkerRunLoop.cpp

示例9: WaitForValidPidFile

pid_t
WaitForValidPidFile(void)
{
    CFAbsoluteTime patience = CFAbsoluteTimeGetCurrent() + kChildStartPidTimeout;
    
    // Poll for a child process and pidfile to be generated, until we lose patience.
    pid_t pid = -1;
    while ((pid = CheckForValidPidFile()) == -1 && (patience - CFAbsoluteTimeGetCurrent() > 0))
        sleep(1);
        
    if (verbosity >= 3)
        LogMessage("Discovered pid %d from pidfile %s\n", pid, pidFile);

    return pid;
}
开发者ID:Brucegx,项目名称:Appstore719,代码行数:15,代码来源:main.c

示例10: main

int
main(int argc, const char * argv[])
{
  int result = 0;
  FSEventStreamRef streamRef;
  Boolean startedOK;
  int flush_seconds = 3600; // When to force-flush any queued events
  
  if(argc < 2 || strcasecmp(argv[1], "--help") == 0) {
    fprintf(stderr, "usage: %s path ...\n", argv[0]);
    exit(1);
  }
  
  const char **paths = &argv[1];
  streamRef = my_FSEventStreamCreate(paths, argc-1);
  
  FSEventStreamScheduleWithRunLoop(streamRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
  
  startedOK = FSEventStreamStart(streamRef);
  if (!startedOK) {
    log_error("FSEventStreamStart(streamRef) failed");
    goto out;
  }
  
  if (flush_seconds >= 0) {
    log_debug("CFAbsoluteTimeGetCurrent() => %.3f", CFAbsoluteTimeGetCurrent());
    CFAllocatorRef allocator = kCFAllocatorDefault;
    CFAbsoluteTime fireDate = CFAbsoluteTimeGetCurrent() + /*settings->*/flush_seconds;
    CFTimeInterval interval = /*settings->*/flush_seconds;
    CFOptionFlags flags = 0;
    CFIndex order = 0;
    CFRunLoopTimerCallBack callback = (CFRunLoopTimerCallBack)timer_callback;
    CFRunLoopTimerContext context = { 0, streamRef, NULL, NULL, NULL };
    CFRunLoopTimerRef timer = CFRunLoopTimerCreate(allocator, fireDate, interval, flags, order, callback, &context);
    CFRunLoopAddTimer(CFRunLoopGetCurrent(), timer, kCFRunLoopDefaultMode);
  }
  
  // Run
  CFRunLoopRun();
  
  // Stop / Invalidate / Release
  FSEventStreamStop(streamRef);
out:
  FSEventStreamInvalidate(streamRef);
  FSEventStreamRelease(streamRef);
  
  return result;
}
开发者ID:rsms,项目名称:eye,代码行数:48,代码来源:eyed.c

示例11: timer_callout_set

int
timer_callout_set(timer_callout_t * callout, 
		  CFAbsoluteTime relative_time, timer_func_t * func, 
		  void * arg1, void * arg2, void * arg3)
{
    CFRunLoopTimerContext 	context =  { 0, NULL, NULL, NULL, NULL };
    CFAbsoluteTime 		wakeup_time;

    if (callout == NULL) {
	return (0);
    }
    timer_cancel(callout);
    if (func == NULL) {
	return (0);
    }
    callout->func = func;
    callout->arg1 = arg1;
    callout->arg2 = arg2;
    callout->arg3 = arg3;
    callout->enabled = TRUE;
    callout->time_generation = S_time_generation;
    context.info = callout;
    wakeup_time = CFAbsoluteTimeGetCurrent() + relative_time;
    callout->timer_source 
	= CFRunLoopTimerCreate(NULL, wakeup_time,
			       0.0, 0, 0,
			       timer_callout_process,
			       &context);
    my_log(LOG_DEBUG, "timer: wakeup time is (%0.09g) %0.09g", 
	   relative_time, wakeup_time);
    my_log(LOG_DEBUG, "timer: adding timer source");
    CFRunLoopAddTimer(CFRunLoopGetCurrent(), callout->timer_source,
		      kCFRunLoopDefaultMode);
    return (1);
}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:35,代码来源:timer.c

示例12: timer_callback

static void
timer_callback(CFRunLoopRef timer, void *info) {
  FSEventStreamRef streamRef = (FSEventStreamRef)info;
  log_debug("CFAbsoluteTimeGetCurrent() => %.3f", CFAbsoluteTimeGetCurrent());
  log_debug("FSEventStreamFlushAsync(streamRef = %p)...", streamRef);
  FSEventStreamFlushAsync(streamRef);
}
开发者ID:rsms,项目名称:eye,代码行数:7,代码来源:eyed.c

示例13: rwsched_cfrunloop_relocate_timers_to_main_mode

void
rwsched_cfrunloop_relocate_timers_to_main_mode(rwsched_tasklet_ptr_t sched_tasklet)
{
  //unsigned int i, j;
  unsigned int i;
  rwsched_CFRunLoopTimerRef rwsched_object;
  rwsched_instance_ptr_t instance;

  // Validate input parameters
  RW_CF_TYPE_VALIDATE(sched_tasklet, rwsched_tasklet_ptr_t);

  for (i = 1 ; i < sched_tasklet->cftimer_array->len ; i++) {
    if ((rwsched_object = g_array_index(sched_tasklet->cftimer_array, rwsched_CFRunLoopTimerRef, i)) != NULL) {
      RW_CF_TYPE_VALIDATE(rwsched_object, rwsched_CFRunLoopTimerRef);
      instance = rwsched_object->callback_context.instance;
      RW_CF_TYPE_VALIDATE(instance, rwsched_instance_ptr_t);
      //CFRunLoopRemoveTimer(rwsched_tasklet_CFRunLoopGetCurrent(sched_tasklet), rwsched_object->cf_object, instance->deferred_cfrunloop_mode);
      if (rwsched_object->onetime_timer_fired_while_blocked) {
        //(rwsched_object->cf_callout)(rwsched_object, rwsched_object->cf_context.info);
        RW_ASSERT(rwsched_object->onetime_timer);
        rwsched_object->cf_object = CFRunLoopTimerCreate(rwsched_object->ott.allocator,
                                                         CFAbsoluteTimeGetCurrent()+0.000001,
                                                         0,
                                                         rwsched_object->ott.flags,
                                                         rwsched_object->ott.order,
                                                         rwsched_cftimer_callout_intercept,
                                                         &rwsched_object->tmp_context);
        rwsched_object->onetime_timer_fired_while_blocked = 0;
      }
      CFRunLoopAddTimer(rwsched_tasklet_CFRunLoopGetCurrent(sched_tasklet), rwsched_object->cf_object, instance->main_cfrunloop_mode);
    }
  }
}
开发者ID:gonotes,项目名称:RIFT.ware,代码行数:33,代码来源:cfrunloop_internal.c

示例14: fx_setTimeout

void fx_setTimeout(txMachine* the)
{
	txTimeoutData* data;
#if mxMacOSX
	CFRunLoopTimerContext context;
#endif
	txNumber duration = fxToNumber(the, mxArgv(1)) / 1000;
	
	data = c_malloc(sizeof(txTimeoutData));
	mxElseError(data);
	c_memset(data, 0, sizeof(txTimeoutData));
	data->the = the;
	data->function.kind = mxArgv(0)->kind;
	data->function.value = mxArgv(0)->value;
	fxRemember(the, &(data->function));
	if (mxArgc > 2) {
		data->argument.kind = mxArgv(2)->kind;
		data->argument.value = mxArgv(2)->value;
	}
	fxRemember(the, &(data->argument));
#if mxMacOSX
	memset(&context, 0, sizeof(context));
	context.info = data;
	context.release = fx_setTimeoutRelease;
	data->timer = CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + duration, 0, 0, 0, fx_setTimeoutCallback, &context);
	CFRunLoopAddTimer(CFRunLoopGetCurrent(), data->timer, gxRunLoopMode);
#endif
}
开发者ID:kouis3940,项目名称:kinomajs,代码行数:28,代码来源:xs6Host.c

示例15: WaitForValidPidFile

/* WaitForValidPidFile: Sometimes a valid pidfile will need to be generated first before anything can be done.
 * Arguments: None.
 * Return value: The valid pidfile that was found after waiting for it.
 * Notes: Requires CoreFoundation (checked for by the MP_CHECK_FRAMEWORK_COREFOUNDATION autoconf macro in configure.ac, which comes from acinclude.m4)
 */
pid_t
WaitForValidPidFile(void)
{
    CFAbsoluteTime patience = CFAbsoluteTimeGetCurrent() + kChildStartPidTimeout;

    // Poll for a child process and pidfile to be generated, until we lose patience (literally: "patience" is a variable name).
	// TODO: polling is generally considered bad; could there be a better way to do this?
    pid_t pid = -1;
    while ((pid = CheckForValidPidFile()) == -1 && (patience - CFAbsoluteTimeGetCurrent() > 0))
        sleep(1);

    if (verbosity >= 3)
        LogMessage("Discovered pid %d from pidfile %s\n", pid, pidFile);

    return pid;
}
开发者ID:cooljeanius,项目名称:MacPorts-fork,代码行数:21,代码来源:main.c


注:本文中的CFAbsoluteTimeGetCurrent函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。