1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-05 13:04:54 +02:00

[programming challenge] Our very own sleep.

This commit is contained in:
Michał W. Urbańczyk 2011-12-23 15:09:42 +00:00
parent 4bf1c40211
commit 7b081de638
2 changed files with 16 additions and 3 deletions

View File

@ -68,6 +68,8 @@ const int TACTICS_TIME = 1000;
void postInfoCall(int timeUsed);
void postDecisionCall(int timeUsed, const std::string &text = "AI was thinking over an action", int timeLimit = MAKE_DECIDION_TIME);
void mySleep(int ms);
struct Bomb
{
std::string txt;
@ -75,7 +77,8 @@ struct Bomb
void run(int time)
{
boost::this_thread::sleep(boost::posix_time::milliseconds(time));
//boost::this_thread::sleep(boost::posix_time::milliseconds(time));
mySleep(time);
if(armed)
{
tlog1 << "BOOOM! The bomb exploded! AI was thinking for too long!\n";
@ -97,4 +100,5 @@ struct Bomb
{
armed = 0;
}
};
};

View File

@ -27,7 +27,16 @@ using namespace boost;
std::string NAME = NAME_VER + std::string(" DLL runner");
void mySleep(int ms)
{
CheckTime timer;
#ifdef _WIN32
Sleep(ms);
#else
usleep(ms * 1000);
#endif
tlog0 << "We were ordered to sleep for " << ms << " ms and we did for " << timer.timeSinceStart() << std::endl;
}
int main(int argc, char** argv)
{