mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-12 16:38:08 +00:00
artifact cache cancellation mutex -> semaphore (fixes cancellation thread on linux - we cannot take/drop across threads with mutexes); flip no_meta -> meta
This commit is contained in:
@@ -53,9 +53,9 @@ mkdir -p build
|
||||
mkdir -p local
|
||||
|
||||
# --- Build & Run Metaprogram -------------------------------------------------
|
||||
if [ -v no_meta ]; then echo "[skipping metagen]"; fi
|
||||
if [ ! -v no_meta ]
|
||||
if [ ! -v meta ]
|
||||
then
|
||||
echo "[doing metagen]"
|
||||
cd build
|
||||
$compile_debug ../src/metagen/metagen_main.c $compile_link $out metagen
|
||||
./metagen
|
||||
|
||||
@@ -19,8 +19,7 @@ ac_init(void)
|
||||
ac_shared->req_batches[idx].arena = arena_alloc();
|
||||
}
|
||||
ac_shared->cancel_thread = thread_launch(ac_cancel_thread_entry_point, 0);
|
||||
ac_shared->cancel_thread_mutex = mutex_alloc();
|
||||
mutex_take(ac_shared->cancel_thread_mutex);
|
||||
ac_shared->cancel_thread_semaphore = semaphore_alloc(0, 1, str8_zero());
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
@@ -218,7 +217,7 @@ ac_async_tick(void)
|
||||
//
|
||||
if(lane_idx() == 0)
|
||||
{
|
||||
mutex_drop(ac_shared->cancel_thread_mutex);
|
||||
semaphore_drop(ac_shared->cancel_thread_semaphore);
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
@@ -590,7 +589,7 @@ ac_async_tick(void)
|
||||
//
|
||||
if(lane_idx() == 0)
|
||||
{
|
||||
mutex_take(ac_shared->cancel_thread_mutex);
|
||||
semaphore_take(ac_shared->cancel_thread_semaphore, max_U64);
|
||||
}
|
||||
scratch_end(scratch);
|
||||
}
|
||||
@@ -604,7 +603,7 @@ ac_cancel_thread_entry_point(void *p)
|
||||
for(;;)
|
||||
{
|
||||
os_sleep_milliseconds(50);
|
||||
MutexScope(ac_shared->cancel_thread_mutex)
|
||||
semaphore_take(ac_shared->cancel_thread_semaphore, max_U64);
|
||||
{
|
||||
for EachIndex(cache_slot_idx, ac_shared->cache_slots_count)
|
||||
{
|
||||
@@ -650,5 +649,6 @@ ac_cancel_thread_entry_point(void *p)
|
||||
}
|
||||
}
|
||||
}
|
||||
semaphore_drop(ac_shared->cancel_thread_semaphore);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ struct AC_Shared
|
||||
|
||||
// rjf: cancel thread
|
||||
Thread cancel_thread;
|
||||
Mutex cancel_thread_mutex;
|
||||
Semaphore cancel_thread_semaphore;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
@@ -57,9 +57,6 @@ main_thread_base_entry_point(int arguments_count, char **arguments)
|
||||
#if defined(ARTIFACT_CACHE_H) && !defined(AC_INIT_MANUAL)
|
||||
ac_init();
|
||||
#endif
|
||||
#if defined(ASYNC_H) && !defined(ASYNC_INIT_MANUAL)
|
||||
async_init(&cmdline);
|
||||
#endif
|
||||
#if defined(CONTENT_H) && !defined(C_INIT_MANUAL)
|
||||
c_init();
|
||||
#endif
|
||||
|
||||
@@ -969,11 +969,7 @@ internal Mutex
|
||||
os_mutex_alloc(void)
|
||||
{
|
||||
OS_LNX_Entity *entity = os_lnx_entity_alloc(OS_LNX_EntityKind_Mutex);
|
||||
pthread_mutexattr_t attr;
|
||||
pthread_mutexattr_init(&attr);
|
||||
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
|
||||
int init_result = pthread_mutex_init(&entity->mutex_handle, &attr);
|
||||
pthread_mutexattr_destroy(&attr);
|
||||
int init_result = pthread_mutex_init(&entity->mutex_handle, 0);
|
||||
if(init_result == -1)
|
||||
{
|
||||
os_lnx_entity_release(entity);
|
||||
|
||||
Reference in New Issue
Block a user