summaryrefslogtreecommitdiff
path: root/libs/JSystem/src/JAudio2/JASCmdStack.cpp
blob: beaeee492e99b281fc53dcad96bdbe512091a8a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// JASCmdStack
//

#include "JSystem/JSystem.h" // IWYU pragma: keep

#include "JSystem/JAudio2/JASCmdStack.h"
#include "JSystem/JAudio2/JASCriticalSection.h"
#include <os.h>

JASPortCmd::TPortHead JASPortCmd::sCommandListOnce;

JASPortCmd::TPortHead JASPortCmd::sCommandListStay;

bool JASPortCmd::addPortCmdOnce() {
	JASCriticalSection cs;
	return sCommandListOnce.append(this);
}

bool JASPortCmd::setPortCmd(Command func, JASPortArgs* args) {
	JUT_ASSERT(81, func != NULL);
	if (getSupervisor()) {
		return false;
	}
	mFunc = func;
	mArgs = args;
	return true;
}

void JASPortCmd::execAllCommand() {
	sCommandListOnce.execCommandOnce();
	sCommandListStay.execCommandStay();
}

void JASPortCmd::TPortHead::execCommandOnce() {
	JASCriticalSection cs;
	JSULink<JASPortCmd>* next;
	for (JSULink<JASPortCmd>* link = getFirst(); link != NULL; link = next) {
		next = link->getNext();
		JASPortCmd* cmd = link->getObject();
		cmd->getFunc()(cmd->getArgs());
		remove(link);
	}
}

void JASPortCmd::TPortHead::execCommandStay() {
	JASCriticalSection cs;
	for (JSULink<JASPortCmd>* link = getFirst(); link != NULL; link = link->getNext()) {
		JASPortCmd* cmd = link->getObject();
		cmd->getFunc()(cmd->getArgs());
	}
}