mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-11 16:54:42 +00:00
Codechange: Use platform independent C++11 function for sleeping on a thread.
This commit is contained in:
parent
94c5269fa7
commit
ae748166d0
@ -21,6 +21,7 @@
|
||||
#include "network/network_func.h"
|
||||
#include "window_func.h"
|
||||
#include "newgrf_debug.h"
|
||||
#include "thread.h"
|
||||
|
||||
#include "table/palettes.h"
|
||||
#include "table/string_colours.h"
|
||||
|
@ -75,7 +75,6 @@ void HandleKeypress(uint keycode, WChar key);
|
||||
void HandleTextInput(const char *str, bool marked = false, const char *caret = NULL, const char *insert_location = NULL, const char *replacement_end = NULL);
|
||||
void HandleCtrlChanged();
|
||||
void HandleMouseEvents();
|
||||
void CSleep(int milliseconds);
|
||||
void UpdateWindows();
|
||||
|
||||
void DrawMouseCursor();
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "../gfx_func.h"
|
||||
#include "extmidi.h"
|
||||
#include "../base_media_base.h"
|
||||
#include "../thread.h"
|
||||
#include "midifile.hpp"
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "network_base.h"
|
||||
#include "network_client.h"
|
||||
#include "../core/backup_type.hpp"
|
||||
#include "../thread.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
|
||||
|
@ -205,15 +205,6 @@ bool GetClipboardContents(char *buffer, const char *last)
|
||||
}
|
||||
|
||||
|
||||
void CSleep(int milliseconds)
|
||||
{
|
||||
#ifndef __INNOTEK_LIBC__
|
||||
delay(milliseconds);
|
||||
#else
|
||||
usleep(milliseconds * 1000);
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *FS2OTTD(const char *name) {return name;}
|
||||
const char *OTTD2FS(const char *name) {return name;}
|
||||
|
||||
|
@ -273,14 +273,6 @@ bool GetClipboardContents(char *buffer, const char *last)
|
||||
#endif
|
||||
|
||||
|
||||
/* multi os compatible sleep function */
|
||||
|
||||
void CSleep(int milliseconds)
|
||||
{
|
||||
usleep(milliseconds * 1000);
|
||||
}
|
||||
|
||||
|
||||
#ifndef __APPLE__
|
||||
uint GetCPUCoreCount()
|
||||
{
|
||||
|
@ -544,12 +544,6 @@ bool GetClipboardContents(char *buffer, const char *last)
|
||||
}
|
||||
|
||||
|
||||
void CSleep(int milliseconds)
|
||||
{
|
||||
Sleep(milliseconds);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convert to OpenTTD's encoding from that of the local environment.
|
||||
* When the project is built in UNICODE, the system codepage is irrelevant and
|
||||
|
@ -20,6 +20,15 @@
|
||||
class OTTDThreadExitSignal { };
|
||||
|
||||
|
||||
/**
|
||||
* Sleep on the current thread for a defined time.
|
||||
* @param milliseconds Time to sleep for in milliseconds.
|
||||
*/
|
||||
inline void CSleep(int milliseconds)
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of processor cores in the system, including HyperThreading or similar.
|
||||
* @return Total number of processor cores.
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "../core/random_func.hpp"
|
||||
#include "../core/math_func.hpp"
|
||||
#include "../framerate_type.h"
|
||||
#include "../thread.h"
|
||||
#include "allegro_v.h"
|
||||
#include <allegro.h>
|
||||
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "../../core/math_func.hpp"
|
||||
#include "../../texteff.hpp"
|
||||
#include "../../window_func.h"
|
||||
#include "../../thread.h"
|
||||
|
||||
#import <sys/time.h> /* gettimeofday */
|
||||
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "../../core/sort_func.hpp"
|
||||
#include "cocoa_v.h"
|
||||
#include "../../gfx_func.h"
|
||||
#include "../../thread.h"
|
||||
#include "../../os/macosx/macos.h"
|
||||
|
||||
/**
|
||||
@ -174,7 +175,7 @@ class FullscreenSubdriver : public CocoaSubdriver {
|
||||
|
||||
double adjustment = (target - position) / linesPerSecond;
|
||||
|
||||
CSleep((uint32)(adjustment * 1000));
|
||||
CSleep((uint32)adjustment * 1000);
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "../company_func.h"
|
||||
#include "../core/random_func.hpp"
|
||||
#include "../saveload/saveload.h"
|
||||
#include "../thread.h"
|
||||
#include "dedicated_v.h"
|
||||
|
||||
#ifdef __OS2__
|
||||
|
Loading…
Reference in New Issue
Block a user