mirror of https://github.com/bsnes-emu/bsnes.git
Allow threads to be terminated
This commit is contained in:
parent
cee9704330
commit
a9a9d8927f
|
@ -20,6 +20,7 @@ extern unique_pointer<Emulator::Interface> emulator;
|
|||
#include <nall/encode/zip.hpp>
|
||||
#include <nall/hash/crc16.hpp>
|
||||
#include <nall/atomic-queue.hpp>
|
||||
#include <nall/thread.hpp>
|
||||
|
||||
#include "program/program.hpp"
|
||||
#include "input/input.hpp"
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace nall {
|
|||
|
||||
struct thread {
|
||||
inline auto join() -> void;
|
||||
inline auto cancel() -> void;
|
||||
|
||||
static inline auto create(const function<void (uintptr)>& callback, uintptr parameter = 0, uint stacksize = 0) -> thread;
|
||||
static inline auto detach() -> void;
|
||||
|
@ -66,6 +67,11 @@ auto thread::exit() -> void {
|
|||
pthread_exit(nullptr);
|
||||
}
|
||||
|
||||
auto thread::cancel() -> void {
|
||||
pthread_cancel(handle);
|
||||
pthread_join(handle, nullptr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#elif defined(API_WINDOWS)
|
||||
|
@ -75,6 +81,7 @@ namespace nall {
|
|||
struct thread {
|
||||
inline ~thread();
|
||||
inline auto join() -> void;
|
||||
inline auto cancel() -> void;
|
||||
|
||||
static inline auto create(const function<void (uintptr)>& callback, uintptr parameter = 0, uint stacksize = 0) -> thread;
|
||||
static inline auto detach() -> void;
|
||||
|
@ -132,6 +139,12 @@ auto thread::exit() -> void {
|
|||
ExitThread(0);
|
||||
}
|
||||
|
||||
auto thread::cancel() -> void {
|
||||
TerminateThread(handle, 0);
|
||||
WaitForSingleObject(handle, INFINITE);
|
||||
CloseHandle(handle);
|
||||
handle = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue