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