diff options
| author | 2024-10-24 13:15:29 -0400 | |
|---|---|---|
| committer | 2024-10-24 13:15:29 -0400 | |
| commit | 082db391349f08c435ea22b8643c8c8f7c2e429d (patch) | |
| tree | e5323e3fd4e9b7c3526b2e7aea9f14f5e1248ab7 /src/util | |
| parent | b8abe660fab174d37f8f49142f2261e93f463527 (diff) | |
| download | libnaunet-082db391349f08c435ea22b8643c8c8f7c2e429d.tar.gz libnaunet-082db391349f08c435ea22b8643c8c8f7c2e429d.tar.bz2 libnaunet-082db391349f08c435ea22b8643c8c8f7c2e429d.zip | |
Add packet_cache_flush() and thread canceltype
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/util')
| -rw-r--r-- | src/util/thread/thread.h | 15 | ||||
| -rw-r--r-- | src/util/thread/thread_linux.c | 7 | ||||
| -rw-r--r-- | src/util/thread/thread_windows.c | 8 |
3 files changed, 27 insertions, 3 deletions
diff --git a/src/util/thread/thread.h b/src/util/thread/thread.h index 6a04647..0c5042e 100644 --- a/src/util/thread/thread.h +++ b/src/util/thread/thread.h @@ -8,6 +8,18 @@ #include "../../winwrap.h" #endif +#ifndef _WIN32 +enum { + AKI_THREAD_CANCEL_DEFERRED = PTHREAD_CANCEL_DEFERRED, + AKI_THREAD_CANCEL_ASYNCHRONOUS = PTHREAD_CANCEL_ASYNCHRONOUS +}; +#else +enum { + AKI_THREAD_CANCEL_DEFERRED = 0, + AKI_THREAD_CANCEL_ASYNCHRONOUS +}; +#endif + struct aki_thread { #ifndef _WIN32 pthread_t thread; @@ -51,7 +63,8 @@ void aki_thread_sleep(aki_os_tstamp delay); void aki_thread_create(struct aki_thread *thread, aki_thread_func func, void *userdata); void aki_thread_join(struct aki_thread *thread); -//void aki_thread_cancel(struct aki_thread *thread); +void aki_thread_cancel(struct aki_thread *thread); +void aki_thread_setcanceltype(s32 type); //void aki_thread_detach(struct aki_thread *thread); void aki_mutex_init(struct aki_mutex *mutex); diff --git a/src/util/thread/thread_linux.c b/src/util/thread/thread_linux.c index 6df84e9..04b0868 100644 --- a/src/util/thread/thread_linux.c +++ b/src/util/thread/thread_linux.c @@ -22,12 +22,17 @@ void aki_thread_join(struct aki_thread *thread) pthread_join(thread->thread, NULL); } -/* void aki_thread_cancel(struct aki_thread *thread) { pthread_cancel(thread->thread); } +void aki_thread_setcanceltype(s32 type) +{ + pthread_setcanceltype(type, NULL); +} + +/* void aki_thread_detach(struct aki_thread *thread) { pthread_detach(thread->thread); diff --git a/src/util/thread/thread_windows.c b/src/util/thread/thread_windows.c index b948d3e..b7bc0ec 100644 --- a/src/util/thread/thread_windows.c +++ b/src/util/thread/thread_windows.c @@ -18,11 +18,17 @@ void aki_thread_join(struct aki_thread *thread) CloseHandle(thread->thread); } -/* void aki_thread_cancel(struct aki_thread *thread) { + (void)thread; } +void aki_thread_setcanceltype(s32 type) +{ + (void)type; +} + +/* void aki_thread_detach(struct aki_thread *thread) { } |