-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUTestSrsQueue.cpp
More file actions
39 lines (31 loc) · 997 Bytes
/
UTestSrsQueue.cpp
File metadata and controls
39 lines (31 loc) · 997 Bytes
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
#include "queue.h"
#include <iostream>
using namespace std;
int main() {
SrsFileQueue s("mwt");
char teststr[11] = "mwtmwtmwt1";
int pushnums = 0;
int popnums = 0;
for(int i = 0; i < 200; i++) {
int j = random() % 2;
if(j) {
pushnums++;
s.push(teststr,10);
} else {
if(!s.empty()) {
popnums++;
Fqueue::record r = s.pop();
cout << "pop str: " << r.ptr.get() << "str.size(): " << r.size << endl;
}
}
}
//最后把队列所有的数据出栈
while(!s.empty()) {
Fqueue::record r = s.pop();
popnums++;
cout << "pop str: " << r.ptr.get() << "str.size(): " << r.size << endl;
}
std::cout << "push nums: " << pushnums << std::endl;
std::cout << "pop nums: " << popnums << std::endl;
//在这个文件队列析构的时候会销毁空闲池
}