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:
parent
4bf1c40211
commit
7b081de638
@ -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;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user