本文整理汇总了C++中iceutil::Time::toMilliSeconds方法的典型用法代码示例。如果您正苦于以下问题:C++ Time::toMilliSeconds方法的具体用法?C++ Time::toMilliSeconds怎么用?C++ Time::toMilliSeconds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iceutil::Time
的用法示例。
在下文中一共展示了Time::toMilliSeconds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ThreadSyscallException
bool
IceUtilInternal::Semaphore::timedWait(const IceUtil::Time& timeout) const
{
long msec = (long)timeout.toMilliSeconds();
int rc = WaitForSingleObject(_sem, msec);
if(rc != WAIT_TIMEOUT && rc != WAIT_OBJECT_0)
{
throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, GetLastError());
}
return rc != WAIT_TIMEOUT;
}
示例2: InvalidTimeoutException
bool
IceUtilInternal::Semaphore::timedWait(const IceUtil::Time& timeout) const
{
IceUtil::Int64 msTimeout = timeout.toMilliSeconds();
if(msTimeout < 0 || msTimeout > 0x7FFFFFFF)
{
throw IceUtil::InvalidTimeoutException(__FILE__, __LINE__, timeout);
}
DWORD rc = WaitForSingleObject(_sem, static_cast<DWORD>(msTimeout));
if(rc != WAIT_TIMEOUT && rc != WAIT_OBJECT_0)
{
throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, GetLastError());
}
return rc != WAIT_TIMEOUT;
}
示例3: checkedSleep
void checkedSleep( gbxutilacfr::Stoppable* activity, const IceUtil::Time& duration, int checkIntervalMs )
{
assert( activity && "Null activity pointer" );
// Handle durations less than the check interval
if ( duration.toMilliSeconds() < checkIntervalMs )
{
IceUtil::ThreadControl::sleep( duration );
return;
}
IceUtil::Time wakeupTime = IceUtil::Time::now() + duration;
IceUtil::Time checkInterval = IceUtil::Time::milliSeconds( checkIntervalMs );
while ( !activity->isStopping() && IceUtil::Time::now() < wakeupTime )
{
IceUtil::ThreadControl::sleep( checkInterval );
}
}
示例4: m
int
main(int argc, char* argv[])
{
Ice::InitializationData initData;
initData.properties = Ice::createProperties();
initData.properties->load("config");
Ice::CommunicatorPtr communicator = Ice::initialize(argc, argv, initData);
if(argc > 1)
{
cerr << argv[0] << ": too many arguments" << endl;
return EXIT_FAILURE;
}
Freeze::ConnectionPtr connection = Freeze::createConnection(communicator, "backup");
IntLongMap m(connection, "IntLongMap", true);
const int size = 10000;
if(m.size() == 0)
{
cout << "********* Creating new map ***********" << endl;
Freeze::TransactionHolder txHolder(connection);
IceUtil::Time time = IceUtil::Time::now();
IceUtil::Int64 ms = time.toMilliSeconds();
for(int i = 0; i < size; ++i)
{
m.insert(IntLongMap::value_type(i, ms));
}
txHolder.commit();
}
cout << "Updating map" << endl;
for(;;)
{
int count = 0;
Freeze::TransactionHolder txHolder(connection);
IceUtil::Time time = IceUtil::Time::now();
IceUtil::Int64 ms = time.toMilliSeconds();
IntLongMap::iterator p = m.begin();
IceUtil::Int64 oldMs = p->second;
do
{
if(p->second != oldMs)
{
cerr << "old time (ms) == " << oldMs << endl;
cerr << "current current (ms) == " << p->second << endl;
}
test(p->second == oldMs);
p.set(ms);
count++;
} while(++p != m.end());
cout << "Read " << IceUtil::Time::milliSeconds(oldMs).toDateTime() << " in all records;"
<< " updating with " << time.toDateTime() << " ... " << flush;
txHolder.commit();
cout << "done" << endl;
test(count == size);
}
connection->close();
communicator->destroy();
return EXIT_SUCCESS;
}