aboutsummaryrefslogtreecommitdiff
path: root/src/threading.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-12-18 22:49:10 +0000
committergingerBill <bill@gingerbill.org>2022-12-18 22:49:10 +0000
commitc1f5be24e28c41efbbbe6d116d533b55d48bbf82 (patch)
treec000ca55e7b69ea39a6e3a32714690b350708414 /src/threading.cpp
parent6cdec65ca1fd13a4d86d83a6715cbaaff7115cd7 (diff)
Remove dead code in the compiler
Diffstat (limited to 'src/threading.cpp')
-rw-r--r--src/threading.cpp50
1 files changed, 8 insertions, 42 deletions
diff --git a/src/threading.cpp b/src/threading.cpp
index 511d1b477..b74d087b4 100644
--- a/src/threading.cpp
+++ b/src/threading.cpp
@@ -1,6 +1,10 @@
#if defined(GB_SYSTEM_LINUX)
#include <signal.h>
#endif
+#if defined(GB_SYSTEM_WINDOWS)
+ #pragma warning(push)
+ #pragma warning(disable: 4505)
+#endif
struct BlockingMutex;
struct RecursiveMutex;
@@ -269,48 +273,6 @@ struct MutexGuard {
}
#endif
-
-
-struct Barrier {
- BlockingMutex mutex;
- Condition cond;
- isize index;
- isize generation_id;
- isize thread_count;
-};
-
-gb_internal void barrier_init(Barrier *b, isize thread_count) {
- mutex_init(&b->mutex);
- condition_init(&b->cond);
- b->index = 0;
- b->generation_id = 0;
- b->thread_count = 0;
-}
-
-gb_internal void barrier_destroy(Barrier *b) {
- condition_destroy(&b->cond);
- mutex_destroy(&b->mutex);
-}
-
-// Returns true if it is the leader
-gb_internal bool barrier_wait(Barrier *b) {
- mutex_lock(&b->mutex);
- defer (mutex_unlock(&b->mutex));
- isize local_gen = b->generation_id;
- b->index += 1;
- if (b->index < b->thread_count) {
- while (local_gen == b->generation_id && b->index < b->thread_count) {
- condition_wait(&b->cond, &b->mutex);
- }
- return false;
- }
- b->index = 0;
- b->generation_id += 1;
- condition_broadcast(&b->cond);
- return true;
-}
-
-
gb_internal u32 thread_current_id(void) {
@@ -494,3 +456,7 @@ gb_internal void thread_set_name(Thread *t, char const *name) {
#endif
}
+
+#if defined(GB_SYSTEM_WINDOWS)
+ #pragma warning(pop)
+#endif \ No newline at end of file