summaryrefslogtreecommitdiff
path: root/drivers/windows/thread_windows.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/windows/thread_windows.cpp')
-rw-r--r--drivers/windows/thread_windows.cpp61
1 files changed, 27 insertions, 34 deletions
diff --git a/drivers/windows/thread_windows.cpp b/drivers/windows/thread_windows.cpp
index dbe2f93fd4..e6143b4af3 100644
--- a/drivers/windows/thread_windows.cpp
+++ b/drivers/windows/thread_windows.cpp
@@ -32,24 +32,23 @@
#include "os/memory.h"
-
Thread::ID ThreadWindows::get_ID() const {
- return id;
+ return id;
}
-Thread* ThreadWindows::create_thread_windows() {
+Thread *ThreadWindows::create_thread_windows() {
- return memnew( ThreadWindows );
+ return memnew(ThreadWindows);
}
-DWORD ThreadWindows::thread_callback( LPVOID userdata ) {
+DWORD ThreadWindows::thread_callback(LPVOID userdata) {
- ThreadWindows *t=reinterpret_cast<ThreadWindows*>(userdata);
+ ThreadWindows *t = reinterpret_cast<ThreadWindows *>(userdata);
ScriptServer::thread_enter(); //scripts may need to attach a stack
- t->id=(ID)GetCurrentThreadId(); // must implement
+ t->id = (ID)GetCurrentThreadId(); // must implement
t->callback(t->user);
ScriptServer::thread_exit();
@@ -57,53 +56,47 @@ DWORD ThreadWindows::thread_callback( LPVOID userdata ) {
return 0;
}
-Thread* ThreadWindows::create_func_windows(ThreadCreateCallback p_callback,void *p_user,const Settings&) {
-
- ThreadWindows *tr= memnew(ThreadWindows);
- tr->callback=p_callback;
- tr->user=p_user;
- tr->handle=CreateThread(
- NULL, // default security attributes
- 0, // use default stack size
- thread_callback, // thread function name
- tr, // argument to thread function
- 0, // use default creation flags
- NULL); // returns the thread identifier
-
+Thread *ThreadWindows::create_func_windows(ThreadCreateCallback p_callback, void *p_user, const Settings &) {
+
+ ThreadWindows *tr = memnew(ThreadWindows);
+ tr->callback = p_callback;
+ tr->user = p_user;
+ tr->handle = CreateThread(
+ NULL, // default security attributes
+ 0, // use default stack size
+ thread_callback, // thread function name
+ tr, // argument to thread function
+ 0, // use default creation flags
+ NULL); // returns the thread identifier
+
return tr;
}
Thread::ID ThreadWindows::get_thread_ID_func_windows() {
return (ID)GetCurrentThreadId(); //must implement
}
-void ThreadWindows::wait_to_finish_func_windows(Thread* p_thread) {
+void ThreadWindows::wait_to_finish_func_windows(Thread *p_thread) {
-
- ThreadWindows *tp=static_cast<ThreadWindows*>(p_thread);
+ ThreadWindows *tp = static_cast<ThreadWindows *>(p_thread);
ERR_FAIL_COND(!tp);
- WaitForSingleObject( tp->handle, INFINITE );
+ WaitForSingleObject(tp->handle, INFINITE);
CloseHandle(tp->handle);
- //`memdelete(tp);
+ //`memdelete(tp);
}
-
void ThreadWindows::make_default() {
- create_func=create_func_windows;
- get_thread_ID_func=get_thread_ID_func_windows;
- wait_to_finish_func=wait_to_finish_func_windows;
-
+ create_func = create_func_windows;
+ get_thread_ID_func = get_thread_ID_func_windows;
+ wait_to_finish_func = wait_to_finish_func_windows;
}
ThreadWindows::ThreadWindows() {
- handle=NULL;
+ handle = NULL;
}
-
ThreadWindows::~ThreadWindows() {
-
}
-
#endif