本文整理汇总了C++中GetCurrentTime函数的典型用法代码示例。如果您正苦于以下问题:C++ GetCurrentTime函数的具体用法?C++ GetCurrentTime怎么用?C++ GetCurrentTime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetCurrentTime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: srand
void Monster::JudegeAttack()
{
srand((UINT)GetCurrentTime());
int x = rand()%100;
if(x>98)
{
this->AttackAnimation("monster_attack",5,MonsterDirecton);
}
}
示例2: RunEnqueueDequeueTrial
/*
* Function: RunEnqueueDequeueTrial
* --------------------------------
* Runs the enqueue & dequeue time trials for the specified
* pqueue size. Reports results to cout.
* Note that we just randomly choose numbers to insert.
* The amount of time it takes to do one enqueue/dequeue is
* too small to be accurately measured, so we do many iterations in
* a loop and time that.
*/
void RunEnqueueDequeueTrial(int size)
{
PQueue pq;
for (int i = 0; i < size; i++)
pq.enqueue(RandomInteger(1,size));
cout << "Time to enqueue into " << size << "-element pqueue: " << flush;
double start = GetCurrentTime();
for (int j = 0; j < NumRepetitions; j++)
pq.enqueue(RandomInteger(1, 2*size));
cout << 1000*(GetCurrentTime() - start)/NumRepetitions << " usecs" << endl;
cout << "Time to dequeue from " << size << "-element pqueue: " << flush;
start = GetCurrentTime();
for (int k = 0; k < NumRepetitions; k++)
pq.dequeueMax();
cout << 1000*(GetCurrentTime() - start)/NumRepetitions << " usecs" << endl;
}
示例3: WinMain
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static int iKeep [NUM][4] ;
HDC hdcScr, hdcMem ;
int cx, cy ;
HBITMAP hBitmap ;
HWND hwnd ;
int i, j, x1, y1, x2, y2 ;
if (LockWindowUpdate (hwnd = GetDesktopWindow ()))
{
hdcScr = GetDCEx (hwnd, NULL, DCX_CACHE | DCX_LOCKWINDOWUPDATE) ;
hdcMem = CreateCompatibleDC (hdcScr) ;
cx = GetSystemMetrics (SM_CXSCREEN) / 10 ;
cy = GetSystemMetrics (SM_CYSCREEN) / 10 ;
hBitmap = CreateCompatibleBitmap (hdcScr, cx, cy) ;
SelectObject (hdcMem, hBitmap) ;
srand ((int) GetCurrentTime ()) ;
for (i = 0 ; i < 2 ; i++)
for (j = 0 ; j < NUM ; j++)
{
if (i == 0)
{
iKeep [j] [0] = x1 = cx * (rand () % 10) ;
iKeep [j] [1] = y1 = cy * (rand () % 10) ;
iKeep [j] [2] = x2 = cx * (rand () % 10) ;
iKeep [j] [3] = y2 = cy * (rand () % 10) ;
}
else
{
x1 = iKeep [NUM - 1 - j] [0] ;
y1 = iKeep [NUM - 1 - j] [1] ;
x2 = iKeep [NUM - 1 - j] [2] ;
y2 = iKeep [NUM - 1 - j] [3] ;
}
BitBlt (hdcMem, 0, 0, cx, cy, hdcScr, x1, y1, SRCCOPY) ;
BitBlt (hdcScr, x1, y1, cx, cy, hdcScr, x2, y2, SRCCOPY) ;
BitBlt (hdcScr, x2, y2, cx, cy, hdcMem, 0, 0, SRCCOPY) ;
Sleep (10) ;
}
DeleteDC (hdcMem) ;
ReleaseDC (hwnd, hdcScr) ;
DeleteObject (hBitmap) ;
LockWindowUpdate (NULL) ;
}
return FALSE ;
}
示例4: kernel_main
/*======================================================================*
kernel_main
*======================================================================*/
PUBLIC int kernel_main()
{
Init8259A();
Init8253();
SetIRQ();
k_reenter = -1;
ticks = 0;
get_boot_params(&BootParam);
GetCurrentTime(&systime); //?áè?RTCê±??
int i, j, eflags, prio;
u8 rpl;
u8 priv;
TASK * t;
PROCESS * p = proc_table;
char * stk = task_stack + STACK_SIZE_TOTAL + 0x4000;
for (i = 0; i < NR_TASKS + NR_PROCS; i++,p++,t++) {
if (i >= NR_TASKS + NR_NATIVE_PROCS)
{
p->p_flags = FREE_SLOT;
p->ldt_sel = SELECTOR_LDT_FIRST + (i << 3); //空槽也要给LDT赋值否则调度任务会#GP异常
continue;
}
if (i < NR_TASKS) {
t = task_table + i;
priv = PRIVILEGE_TASK;
rpl = RPL_TASK;
eflags = 0x1202;
prio = 1;
}
else {
t = user_proc_table + (i - NR_TASKS);
priv = PRIVILEGE_USER;
rpl = RPL_USER;
eflags = 0x202;
prio = 1;
}
strcpy(p->name, t->name);
p->p_parent = NO_TASK;
if (strcmp(t->name, "INIT") != 0) {
p->ldts[INDEX_LDT_C] = gdt[SELECTOR_KERNEL_CS >> 3];
p->ldts[INDEX_LDT_RW] = gdt[SELECTOR_KERNEL_DS >> 3];
p->ldts[INDEX_LDT_C].attr1 = DA_C | priv << 5;
p->ldts[INDEX_LDT_RW].attr1 = DA_DRW | priv << 5;
}
else {
示例5: EffectEnd
// https://w3c.github.io/web-animations/#finish-an-animation
void
Animation::Finish(ErrorResult& aRv)
{
if (mPlaybackRate == 0 ||
(mPlaybackRate > 0 && EffectEnd() == TimeDuration::Forever())) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
AutoMutationBatchForAnimation mb(*this);
// Seek to the end
TimeDuration limit =
mPlaybackRate > 0 ? TimeDuration(EffectEnd()) : TimeDuration(0);
bool didChange = GetCurrentTime() != Nullable<TimeDuration>(limit);
SilentlySetCurrentTime(limit);
// If we are paused or play-pending we need to fill in the start time in
// order to transition to the finished state.
//
// We only do this, however, if we have an active timeline. If we have an
// inactive timeline we can't transition into the finished state just like
// we can't transition to the running state (this finished state is really
// a substate of the running state).
if (mStartTime.IsNull() &&
mTimeline &&
!mTimeline->GetCurrentTime().IsNull()) {
mStartTime.SetValue(mTimeline->GetCurrentTime().Value() -
limit.MultDouble(1.0 / mPlaybackRate));
didChange = true;
}
// If we just resolved the start time for a pause or play-pending
// animation, we need to clear the task. We don't do this as a branch of
// the above however since we can have a play-pending animation with a
// resolved start time if we aborted a pause operation.
if (!mStartTime.IsNull() &&
(mPendingState == PendingState::PlayPending ||
mPendingState == PendingState::PausePending)) {
if (mPendingState == PendingState::PausePending) {
mHoldTime.SetNull();
}
CancelPendingTasks();
didChange = true;
if (mReady) {
mReady->MaybeResolve(this);
}
}
UpdateTiming(SeekFlag::DidSeek, SyncNotifyFlag::Sync);
if (didChange && IsRelevant()) {
nsNodeUtils::AnimationChanged(this);
}
PostUpdate();
}
示例6: GetCurrentTime
void
Animation::SilentlySetPlaybackRate(double aPlaybackRate)
{
Nullable<TimeDuration> previousTime = GetCurrentTime();
mPlaybackRate = aPlaybackRate;
if (!previousTime.IsNull()) {
ErrorResult rv;
SilentlySetCurrentTime(previousTime.Value());
MOZ_ASSERT(!rv.Failed(), "Should not assert for non-null time");
}
}
示例7:
void
AnimationPlayer::SetSource(Animation* aSource)
{
if (mSource) {
mSource->SetParentTime(Nullable<TimeDuration>());
}
mSource = aSource;
if (mSource) {
mSource->SetParentTime(GetCurrentTime());
}
}
示例8: _GetThreadID
void
Logger::LogEvent(const String &sMessage)
{
long lThread = _GetThreadID();
String sTime = GetCurrentTime();
String sData;
sData.Format(_T("%d\t\"%s\"\t\"%s\"\r\n"), lThread, sTime, sMessage);
_WriteData(sData, Events);
}
示例9: GetCurrentTime
void
Clock::Pause ()
{
//printf ("clock %p (%s) paused\n", this, GetName ());
if (is_paused)
return;
is_paused = true;
begin_pause_time = GetCurrentTime();
}
示例10: SH_RobustAccept
/**
* Performs a robust accept, restarting when interrupted.
* Requires a valid socket (se->fd >= 0).
*/
extern int
SH_RobustAccept(SockEntry se) {
int timeout = se->base->robustTimeout;
uint64_t start = GetCurrentTime();
for (;;) {
int connRes = accept(se->fd, NULL, NULL);
if (connRes >= 0) {
se->lastUsed = GetCurrentTime();
return connRes;
}
int e = errno;
if (e != EAGAIN && e != EINTR) break;
MilliSleep(RobustMillis);
uint64_t now = GetCurrentTime();
double dt = DeltaTime(start, now);
if (dt > timeout) break;
}
se->errCount++;
return -1;
}
示例11: GetCurrentTime
// ProcessEvents
// called by the Process at interrupt time to see if there are
// any events that have timed out
//
void STREAM::ProcessEvents(void)
{
if (qhEvent.IsElements()) {
PEVENT pnextevent = (PEVENT)qhEvent.Head();
ULONG time = GetCurrentTime();
ULONG eventtime = pnextevent->GetEventTime();
if (eventtime <= time)
pnextevent->Report(time);
}
}
示例12: SH_RobustConnect
/**
* Performs a robust connect, restarting when interrupted.
* Requires a valid socket (se->fd >= 0).
*/
extern int
SH_RobustConnect(SockEntry se, struct sockaddr *sap) {
int timeout = se->base->robustTimeout;
uint64_t start = GetCurrentTime();
for (;;) {
int connRes = connect(se->fd, sap, SockAddrLen(sap));
if (connRes >= 0) {
se->lastUsed = GetCurrentTime();
return connRes;
}
int e = errno;
if (e != EAGAIN && e != EINTR) break;
MilliSleep(RobustMillis);
uint64_t now = GetCurrentTime();
double dt = DeltaTime(start, now);
if (dt > timeout) break;
}
se->errCount++;
return -1;
}
示例13: SysMouseAImpl_GetDeviceState
/******************************************************************************
* GetDeviceState : returns the "state" of the mouse.
*
* For the moment, only the "standard" return structure (DIMOUSESTATE) is
* supported.
*/
static HRESULT WINAPI SysMouseAImpl_GetDeviceState(
LPDIRECTINPUTDEVICE8A iface,DWORD len,LPVOID ptr
) {
SysMouseImpl *This = (SysMouseImpl *)iface;
if(This->acquired == 0) return DIERR_NOTACQUIRED;
EnterCriticalSection(&(This->crit));
TRACE("(this=%p,0x%08lx,%p):\n", This, len, ptr);
TRACE("(X: %ld - Y: %ld - Z: %ld L: %02x M: %02x R: %02x)\n",
This->m_state.lX, This->m_state.lY, This->m_state.lZ,
This->m_state.rgbButtons[0], This->m_state.rgbButtons[2], This->m_state.rgbButtons[1]);
/* Copy the current mouse state */
fill_DataFormat(ptr, &(This->m_state), This->wine_df);
/* Initialize the buffer when in relative mode */
if (This->absolute == 0) {
This->m_state.lX = 0;
This->m_state.lY = 0;
This->m_state.lZ = 0;
}
/* Check if we need to do a mouse warping */
if (This->need_warp == WARP_NEEDED && (GetCurrentTime() - This->last_warped > 10)) {
dinput_window_check(This);
TRACE("Warping mouse to %ld - %ld\n", This->mapped_center.x, This->mapped_center.y);
SetCursorPos( This->mapped_center.x, This->mapped_center.y );
This->last_warped = GetCurrentTime();
#ifdef MOUSE_HACK
This->need_warp = WARP_DONE;
#else
This->need_warp = WARP_STARTED;
#endif
}
LeaveCriticalSection(&(This->crit));
return DI_OK;
}
示例14: GetPlayerOwner
//------------------------------------------------------------------------------
// Purpose : Update weapon
//------------------------------------------------------------------------------
void CWeaponSDKMelee::ItemPostFrame( void )
{
CSDKPlayer *pPlayer = GetPlayerOwner();
if ( pPlayer == NULL )
return;
if (IsThrowingGrenade())
{
if (MaintainGrenadeToss())
return;
}
else if ((pPlayer->m_nButtons & IN_ALT2) && !IsThrowingGrenade() && pPlayer->GetAmmoCount(GetAmmoDef()->Index("grenades")) && pPlayer->CanAttack())
{
bool bAllow = (m_flNextPrimaryAttack < GetCurrentTime());
if (m_bInReload)
bAllow = true;
if (bAllow)
{
StartGrenadeToss();
return;
}
}
if (GetSwingTime() > 0 && GetSwingTime() <= GetCurrentTime())
{
Swing();
}
else if ( (pPlayer->m_nButtons & IN_ATTACK) && (m_flNextPrimaryAttack <= GetCurrentTime()) && pPlayer->CanAttack() )
{
PrimaryAttack();
}
else if ( (pPlayer->m_nButtons & IN_ATTACK2) && (m_flNextSecondaryAttack <= GetCurrentTime()) && pPlayer->CanAttack() )
{
SecondaryAttack();
}
else
{
WeaponIdle();
}
}
示例15: SH_NewSockEntryNoCheck
static SockEntry
SH_NewSockEntryNoCheck(SockBase base, int sockFD) {
SockEntry ret = ProxyUtil_StructAlloc(1, SockEntryStruct);
ret->base = base;
ret->next = base->list;
ret->fd = sockFD;
ret->startTime = GetCurrentTime();
ret->lastUsed = ret->startTime;
base->list = ret;
base->nSocks++;
return ret;
}