本文整理汇总了C++中TickCount函数的典型用法代码示例。如果您正苦于以下问题:C++ TickCount函数的具体用法?C++ TickCount怎么用?C++ TickCount使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TickCount函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ticks
/*
ROUTINE: WaitTicks
PURPOSE:
Wait ticks (60.15 Hz), then return.
*/
void WaitTicks(long ticks)
{
ticks+=TickCount();
while(TickCount()+30<ticks)if(CommandPeriod())PrintfExit("User typed cmd-. Exiting.");
while(TickCount()<ticks) ;
return;
}
示例2: SendMicroBlock
PAR_ERROR
SendMicroBlock (unsigned char *p, int len)
{
PAR_ERROR err = CE_NO_ERROR;
short i;
unsigned long t0;
t0 = TickCount ();
CameraOut (0x30, 4);
// i = 0;
// while(i <= len)
for (i = 0; i <= len;)
{
if (!MicroStat ())
{
if (TickCount () - t0 <= 5)
continue;
else
{
err = CE_TX_TIMEOUT;
CameraOut (0x30, 0);
break;
}
}
if (i == len)
break;
if (i == 1)
CameraOut (0x30, control_out & 0xfb);
MicroOut (*(p++));
i++;
t0 = TickCount ();
}
return err;
}
示例3: main
int main ()
{
int ret;
Rect windRect;
long start,end,amount;
/* Initialize all the needed managers. */
InitGraf(&qd.thePort);
InitFonts();
InitWindows();
InitMenus();
TEInit();
InitDialogs(nil);
InitCursor();
//ProfilerInit(collectDetailed, bestTimeBase, 1000, 50);
//ProfilerSetStatus(true);
windRect = qd.screenBits.bounds;
InsetRect(&windRect, 50, 50);
pWindow = NewCWindow(nil, &windRect, "\pMpeg", true, documentProc, (WindowPtr) -1, false, 0);
start = TickCount();
main2();
end = TickCount();
amount = end - start;
fprintf(stderr, "Time taken %d memoryAllocator %d \n", amount,counter);
// ProfilerDump("\pProfile.out");
do {
} while (!Button());
}
示例4: hold_for_visible_delay
void hold_for_visible_delay(
void)
{
long start= TickCount();
while(TickCount()<start+VISIBLE_DELAY);
}
示例5: gp_check_interrupts
/*
* Check messages and interrupts; return true if interrupted.
* This is called frequently - it must be quick!
*/
int gp_check_interrupts(const gs_memory_t *mem)
{
/* static variables need to go away for thread safety */
static unsigned long lastYieldTicks = 0;
int iRetVal = 0;
if ((TickCount() - lastYieldTicks) > 2) {
lastYieldTicks = TickCount();
if (pgsdll_callback) {
/* WARNING: The use of the old gsdll interface is deprecated.
* The caller should use the newer gsapi_set_poll.
* If the caller needs access to "hwndtext", it should do
* this via caller_handle which is passed to poll_fn.
*/
/* the hwnd parameter which is submitted in gsdll_init
* to the DLL is returned in every gsdll_poll message
* in the count parameter
*/
iRetVal = (*pgsdll_callback)(GSDLL_POLL, 0, (long) hwndtext);
} else {
if (mem == NULL) {
/* this is not thread safe */
mem = gs_lib_ctx_get_non_gc_memory_t();
}
if (mem && mem->gs_lib_ctx && mem->gs_lib_ctx->poll_fn)
iRetVal = (*mem->gs_lib_ctx->poll_fn)(mem->gs_lib_ctx->caller_handle);
}
}
return iRetVal;
}
示例6: MyMainThreadYielder
static pascal OSStatus MyMainThreadYielder(void)
{
OSStatus err;
static UInt32 gTimeLastPrinted;
if ( TickCount() > (gTimeLastPrinted + 30) ) {
printf(".");
fflush(stdout);
gTimeLastPrinted = TickCount();
}
#if TARGET_API_MAC_CARBON
{
err = noErr;
if (GetCurrentKeyModifiers() & alphaLock) {
err = kOTCanceledErr;
}
}
#else
{
EventRecord event;
err = noErr;
(void) OSEventAvail(0, &event);
if (event.modifiers & alphaLock) {
err = kOTCanceledErr;
}
}
#endif
return err;
}
示例7: cvWaitKey
CV_IMPL int cvWaitKey (int maxWait)
{
EventRecord theEvent;
// wait at least for one event (to allow mouse, etc. processing), exit if maxWait milliseconds passed (nullEvent)
UInt32 start = TickCount();
int iters=0;
do
{
// remaining time until maxWait is over
UInt32 wait = EventTimeToTicks (maxWait / 1000.0) - (TickCount() - start);
if ((int)wait <= 0)
{
if( maxWait > 0 && iters > 0 )
break;
wait = 1;
}
iters++;
WaitNextEvent (everyEvent, &theEvent, maxWait > 0 ? wait : kDurationForever, NULL);
}
while (lastKey == NO_KEY && theEvent.what != nullEvent);
int key = lastKey;
lastKey = NO_KEY;
return key;
}
示例8: MacIdle
void MacIdle(void)
{
extern logical anywarns;
static long time = 0;
EventRecord myEvent;
WindowPtr whichWindow;
#if TARGET_API_MAC_CARBON
Rect tempRect;
#endif
char theChar;
if (TickCount()<time) return;
if (mac_quit_now) {
anywarns = FALSE; /* kludge so that window doesn't sit around */
my_exit(1);
}
#if !TARGET_API_MAC_CARBON
SystemTask();
#endif
if (WaitNextEvent(everyEvent, &myEvent, 1, nil)) {
if (!SIOUXHandleOneEvent(&myEvent)) switch (myEvent.what) {
case mouseDown:
switch (FindWindow(myEvent.where,&whichWindow)) {
case inMenuBar:
MenuSelect(myEvent.where);
break;
#if !TARGET_API_MAC_CARBON
case inSysWindow:
SystemClick(&myEvent,whichWindow);
break;
#endif
case inContent:
SelectWindow(whichWindow);
break;
case inDrag:
#if TARGET_API_MAC_CARBON
GetRegionBounds(GetGrayRgn(),&tempRect);
DragWindow(whichWindow,myEvent.where,&tempRect);
#else
DragWindow(whichWindow,myEvent.where,&qd.screenBits.bounds);
#endif
break;
}
break;
case keyDown:
theChar = myEvent.message & charCodeMask;
break;
case updateEvt:
BeginUpdate((WindowPtr) myEvent.message);
EndUpdate((WindowPtr) myEvent.message);
break;
}
}
time=TickCount()+20;
}
示例9: domultitask_
int domultitask_( long *sleepTime )
{
if( TickCount() > gNextCheck ) /* Time to check for events again? */
{
getchar(); /* poll for char to have console call WNE */
gNextCheck = TickCount() + gTickSlice; /* Reset the tick count */
}
return 1;
}
示例10: CallSystemTask
static void CallSystemTask()
{
static unsigned long int lastCall;
if (TickCount() < (lastCall + 10)) return;
SystemTask();
lastCall = TickCount();
return;
}
示例11: stay_awake
void stay_awake(
void)
{
if (TickCount()>last_fake_keyboard_event+FAKE_KEYBOARD_EVENT_PERIOD)
{
last_fake_keyboard_event= TickCount();
PostEvent(keyDown, 0);
}
return;
}
示例12: SleepTicks
// Uses usleep to sleep for full duration even if a signal is received
static void SleepTicks(UInt32 ticksToSleep) {
UInt32 endSleep, timeNow, ticksRemaining;
timeNow = TickCount();
ticksRemaining = ticksToSleep;
endSleep = timeNow + ticksToSleep;
while ( (timeNow < endSleep) && (ticksRemaining <= ticksToSleep) ) {
usleep(16667 * ticksRemaining);
timeNow = TickCount();
ticksRemaining = endSleep - timeNow;
}
}
示例13: TickCount
Boolean MCScreenDC::abortkey()
{ /* check for Command-. system abort key */
if (MCabortscript)
return True;
static uint4 alarmcount;
uint4 newcount = TickCount();
if (newcount < alarmcount)
return False;
alarmcount = newcount + 30;
// MW-2008-07-31: [[ Bug 6850 ]] Variable watcher breaks out when using scroll wheel.
// This bug was caused by the previous version of checking for an abortkey causing
// Carbon events to be handled. This can result in things such WheelUp/WheelDown
// events being dispatched *inside* previous invocations.
if (CheckEventQueueForUserCancel())
{
if (MCallowinterrupts && !MCdefaultstackptr -> cantabort())
return True;
else
MCinterrupt = True;
// OK-2010-04-29: [[Bug]] - cantAbort / allowInterrupts not working on OS X
return False;
}
if (MCnsockets != 0)
MCS_handle_sockets();
return False;
}
示例14: filename
// writes the common header info to the stream
void LogMessage::Init(const char* file, int line) {
std::string filename(file);
size_t last_slash_pos = filename.find_last_of("\\/");
if (last_slash_pos != std::string::npos)
filename = filename.substr(last_slash_pos + 1);
stream_ << '[';
stream_ << ::GetCurrentProcessId() << ':';
stream_ << ::GetCurrentThreadId() << ':';
if (log_timestamp) {
time_t t = time(NULL);
struct tm local_time = {0};
localtime_s(&local_time, &t);
struct tm* tm_time = &local_time;
stream_ << std::setfill('0')
<< std::setw(2) << 1 + tm_time->tm_mon
<< std::setw(2) << tm_time->tm_mday
<< '/'
<< std::setw(2) << tm_time->tm_hour
<< std::setw(2) << tm_time->tm_min
<< std::setw(2) << tm_time->tm_sec
<< ':';
}
if (log_tickcount)
stream_ << TickCount() << ':';
if (severity_ >= 0)
stream_ << log_severity_name(severity_);
else
stream_ << "VERBOSE" << -severity_;
stream_ << ":" << filename << "(" << line << ")] ";
message_start_ = stream_.tellp();
}
示例15: tcp_wait
/* wait for MacTCP to finish whatever it's doing, with user cancel
*/
static short tcp_wait(struct tcpstate *ts, tcpinfo *tcp)
{
KeyMap mapkeys;
#define keys ((unsigned char *)mapkeys)
short percent;
while (!tcp_checkdriver()
|| (tcp && (tcp->state & TCP_DNSINUSE) && ! (volatile) tcp->dnrdone)
|| (tcp && (tcp->state & TCP_PBINUSE) && (volatile short) tcp->pb.ioResult == 1)) {
if (ts) {
if (!ts->waiticks) return (0);
percent = ((TickCount() - ts->waitstart) * 100) / ts->waiticks;
if (percent > 100) percent = 100;
if (percent != ts->waitpercent) {
(*ts->tcp_initp)(ts->waitpercent = percent);
}
if (percent == 100) return (0);
}
SystemTask();
GetKeys(mapkeys);
if ((keys[0x37 >> 3] >> (0x37 & 7))
& (keys[0x2f >> 3] >> (0x2f & 7)) & 1) {
return (0);
}
}
return (1);
}