mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-05 02:52:13 +02:00
fixed typos
This commit is contained in:
parent
fac799648e
commit
e3a4e26875
@ -5,9 +5,9 @@
|
||||
* @copyright libnx Authors
|
||||
*/
|
||||
#pragma once
|
||||
#include "../types.h"
|
||||
#include "condvar.h"
|
||||
#include "mutex.h"
|
||||
#include "thread.h"
|
||||
#include "../runtime/util/list.h"
|
||||
|
||||
typedef struct barrier {
|
||||
|
@ -5,13 +5,14 @@
|
||||
* @copyright libnx Authors
|
||||
*/
|
||||
#pragma once
|
||||
#include "../types.h"
|
||||
#include "../kernel/condvar.h"
|
||||
#include "../kernel/mutex.h"
|
||||
#include "../../types.h"
|
||||
#include "../../kernel/condvar.h"
|
||||
#include "../../kernel/rwlock.h"
|
||||
#include "../../kernel/thread.h"
|
||||
|
||||
typedef struct node {
|
||||
void* item;
|
||||
Node* next;
|
||||
struct node* next;
|
||||
} Node;
|
||||
|
||||
typedef struct list {
|
||||
|
@ -6,8 +6,8 @@ void barrierInit(Barrier* b) {
|
||||
if(b->isInited) {
|
||||
return;
|
||||
}
|
||||
listInit(b->threads_registered);
|
||||
listInit(b->threads_waiting);
|
||||
listInit(&b->threads_registered);
|
||||
listInit(&b->threads_waiting);
|
||||
b->isInited = true;
|
||||
mutexUnlock(&b->mutex);
|
||||
}
|
||||
@ -17,39 +17,39 @@ void barrierFree(Barrier* b) {
|
||||
if(!b->isInited) {
|
||||
return;
|
||||
}
|
||||
listFree(b->threads_registered);
|
||||
listFree(b->threads_waiting);
|
||||
listFree(&b->threads_registered);
|
||||
listFree(&b->threads_waiting);
|
||||
b->isInited = false;
|
||||
mutexUnlock(&b->mutex);
|
||||
}
|
||||
|
||||
void barrierRegister(Barrier* b, Thread* thread) {
|
||||
if(listIsInserted(b->threads_registered, (void*)thread)) {
|
||||
if(listIsInserted(&b->threads_registered, (void*)thread)) {
|
||||
return;
|
||||
}
|
||||
listInsertLast(b->threads_registered, (void*)thread);
|
||||
listInsertLast(&b->threads_registered, (void*)thread);
|
||||
}
|
||||
|
||||
void barrierUnregister(Barrier* b, Thread* thread) {
|
||||
listDelete(b->threads_registered, (void*)thread);
|
||||
listDelete(&b->threads_registered, (void*)thread);
|
||||
}
|
||||
|
||||
void barrierWait(Barrier* b, Thread* thread) {
|
||||
if(!listIsInserted(b->threads_registered)) {
|
||||
if(!listIsInserted(&b->threads_registered, thread)) {
|
||||
return;
|
||||
}
|
||||
|
||||
mutexLock(&b->mutex);
|
||||
if(listGetNumNodes(b->threads_registered) == listGetNumNodes(b->threads_waiting)+1) {
|
||||
while(listGetNumNodes(b->threads_waiting) > 0) {
|
||||
Thread* current_thread = listGetItem(b->threads_waiting, 0);
|
||||
if(listGetNumNodes(&b->threads_registered) == listGetNumNodes(&b->threads_waiting)+1) {
|
||||
while(listGetNumNodes(&b->threads_waiting) > 0) {
|
||||
Thread* current_thread = listGetItem(&b->threads_waiting, 0);
|
||||
threadResume(current_thread);
|
||||
listDelete(b->threads_waiting, current_thread);
|
||||
listDelete(&b->threads_waiting, current_thread);
|
||||
}
|
||||
mutexUnlock(&b->mutex);
|
||||
}
|
||||
else {
|
||||
listInsertLast(b->threads_waiting, thread);
|
||||
listInsertLast(&b->threads_waiting, thread);
|
||||
mutexUnlock(&b->mutex);
|
||||
threadPause((void*)thread);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user