annotate TaskManager/Cell/CellBufferManager.cc @ 63:54355e641172

*** empty log message ***
author gongo
date Sun, 17 Feb 2008 10:55:22 +0900
parents f50c74835a9b
children 519d24aa7ac8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
1 #include <stdio.h>
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
2 #include <stdlib.h>
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
3 #include "CellBufferManager.h"
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
4 #include "CellTaskListInfo.h"
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
5
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
6 void
60
f50c74835a9b *** empty log message ***
gongo
parents: 57
diff changeset
7 CellBufferManager::init(void)
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
8 {
63
54355e641172 *** empty log message ***
gongo
parents: 60
diff changeset
9 BufferManager::init(void);
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
10
63
54355e641172 *** empty log message ***
gongo
parents: 60
diff changeset
11 cellTaskListImpl = new CellTaskListInfo;
54355e641172 *** empty log message ***
gongo
parents: 60
diff changeset
12 machineTaskList = new TaskListPtr[machineNum];
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
13
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
14 for (int i = 0; i < machineNum; i++) {
63
54355e641172 *** empty log message ***
gongo
parents: 60
diff changeset
15 machineTaskList[i] = cellTaskListImpl->create();
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
16 }
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
17 }
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
18
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
19 #if 0 // 継承するかもしれないので保存
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
20 void
60
f50c74835a9b *** empty log message ***
gongo
parents: 57
diff changeset
21 CellBufferManager::append_activeTask(HTaskPtr task)
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
22 {
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
23 TaskQueuePtr q;
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
24
63
54355e641172 *** empty log message ***
gongo
parents: 60
diff changeset
25 q = taskQueueImpl->create(task);
54355e641172 *** empty log message ***
gongo
parents: 60
diff changeset
26 activeTaskQueue = taskQueueImpl->append(activeTaskQueue, q);
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
27 }
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
28
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
29 void
60
f50c74835a9b *** empty log message ***
gongo
parents: 57
diff changeset
30 CellBufferManager::append_waitTask(HTaskPtr task)
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
31 {
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
32 TaskQueuePtr q;
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
33
63
54355e641172 *** empty log message ***
gongo
parents: 60
diff changeset
34 q = taskQueueImpl->create(task);
54355e641172 *** empty log message ***
gongo
parents: 60
diff changeset
35 waitTaskQueue = taskQueueImpl->append(waitTaskQueue, q);
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
36 }
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
37
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
38 TaskListPtr
60
f50c74835a9b *** empty log message ***
gongo
parents: 57
diff changeset
39 CellBufferManager::get_available_taskList(void)
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
40 {
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
41 TaskListPtr list, q;
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
42
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
43 list = machineTaskList[0];
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
44
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
45 while (list->next) list = list->next;
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
46
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
47 if (list->length < TASK_MAX_SIZE) {
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
48 return list;
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
49 } else {
63
54355e641172 *** empty log message ***
gongo
parents: 60
diff changeset
50 q = cellTaskListImpl->create();
54355e641172 *** empty log message ***
gongo
parents: 60
diff changeset
51 machineTaskList[0] = cellTaskListImpl->append(machineTaskList[0], q);
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
52 return q;
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
53 }
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
54 }
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
55
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
56 void
60
f50c74835a9b *** empty log message ***
gongo
parents: 57
diff changeset
57 CellBufferManager::clear_taskList(void)
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
58 {
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
59 TaskListPtr p, p1;
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
60
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
61 machineTaskList[0]->length = 0;
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
62
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
63 p = machineTaskList[0]->next;
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
64 while (p) {
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
65 p1 = p;
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
66 p = p->next;
63
54355e641172 *** empty log message ***
gongo
parents: 60
diff changeset
67 cellTaskListImpl->free(p1);
57
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
68 }
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
69 }
1f8a23cdeec3 *** empty log message ***
gongo
parents:
diff changeset
70 #endif