Changeset - r23589:b3521e885d81
[Not reviewed]
master
0 12 0
Michael Lutz - 5 years ago 2019-03-17 10:05:53
michi@icosahedron.de
Codechange: Use platform independent C++11 function for sleeping on a thread.
12 files changed with 17 insertions and 25 deletions:
0 comments (0 inline, 0 general)
src/gfx.cpp
Show inline comments
 
@@ -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"
src/gfx_func.h
Show inline comments
 
@@ -75,7 +75,6 @@ void HandleKeypress(uint keycode, WChar 
 
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();
src/music/extmidi.cpp
Show inline comments
 
@@ -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>
src/network/network_client.cpp
Show inline comments
 
@@ -29,6 +29,7 @@
 
#include "network_base.h"
 
#include "network_client.h"
 
#include "../core/backup_type.hpp"
 
#include "../thread.h"
 

	
 
#include "table/strings.h"
 

	
src/os/os2/os2.cpp
Show inline comments
 
@@ -205,15 +205,6 @@ bool GetClipboardContents(char *buffer, 
 
}
 

	
 

	
 
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;}
 

	
src/os/unix/unix.cpp
Show inline comments
 
@@ -273,14 +273,6 @@ bool GetClipboardContents(char *buffer, 
 
#endif
 

	
 

	
 
/* multi os compatible sleep function */
 

	
 
void CSleep(int milliseconds)
 
{
 
	usleep(milliseconds * 1000);
 
}
 

	
 

	
 
#ifndef __APPLE__
 
uint GetCPUCoreCount()
 
{
src/os/windows/win32.cpp
Show inline comments
 
@@ -544,12 +544,6 @@ bool GetClipboardContents(char *buffer, 
 
}
 

	
 

	
 
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
src/thread.h
Show inline comments
 
@@ -21,6 +21,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.
 
 */
src/video/allegro_v.cpp
Show inline comments
 
@@ -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>
 

	
src/video/cocoa/event.mm
Show inline comments
 
@@ -37,6 +37,7 @@
 
#include "../../core/math_func.hpp"
 
#include "../../texteff.hpp"
 
#include "../../window_func.h"
 
#include "../../thread.h"
 

	
 
#import <sys/time.h> /* gettimeofday */
 

	
src/video/cocoa/fullscreen.mm
Show inline comments
 
@@ -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 Cocoa
 

	
 
		double adjustment = (target - position) / linesPerSecond;
 

	
 
		CSleep((uint32)(adjustment * 1000));
 
		CSleep((uint32)adjustment * 1000);
 
	}
 

	
 

	
src/video/dedicated_v.cpp
Show inline comments
 
@@ -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__
0 comments (0 inline, 0 general)