This commit is contained in:
biosvos
2026-08-07 17:38:18 +09:00
commit 873193a243
9613 changed files with 2755992 additions and 0 deletions
+96
View File
@@ -0,0 +1,96 @@
#include <errno.h>
#include <iostream>
#include <string>
#include <fcntl.h>
#include "FixedQueue.h"
using namespace std;
void *_entry_func(void *arg)
{
CFixedQueue *q = (CFixedQueue*)arg;
for (int i = 0; i < 50; ++i)
{
char p[1204] = {0};
sprintf(p, "########## %i", i);
int r = q->Push(p, strlen(p));
cout << "Tread Push : " << p << "," << r << endl;
sleep(1);
}
return 0;
}
void *_entry_func2(void *arg)
{
CFixedQueue *q = (CFixedQueue*)arg;
for (int i = 0; i < 30; ++i)
{
char p[1204] = {0};
int r = q->Pop(p, sizeof(p));
cout << "Tread Pop(1) : " << p << "," << r << endl;
sleep(4);
}
return 0;
}
void *_entry_func3(void *arg)
{
CFixedQueue *q = (CFixedQueue*)arg;
for (int i = 0; i < 20; ++i)
{
char p[1204] = {0};
int r = q->Pop(p, sizeof(p));
cout << "Tread Pop(2) : " << p << "," << r << endl;
sleep(2);
}
return 0;
}
int main ( int argc, char * argv[] )
{
CFixedQueue q(2048, 50);
char * p = "12345";
q.Push(p, strlen(p));
char temp[1204] = {0};
q.Pop(temp, sizeof(temp));
cout << "#### "<< temp << endl;
pthread_t workerthread = 0;
// start thread
int ret = pthread_create(&workerthread, 0, _entry_func, (void*)&q);
if (ret != 0)
{
cerr << "Client Thread create failed.[" << errno << "]";
return EXIT_FAILURE;
}
ret = pthread_create(&workerthread, 0, _entry_func2, (void*)&q);
if (ret != 0)
{
cerr << "Client Thread create2 failed.[" << errno << "]";
return EXIT_FAILURE;
}
cout << "############### " << endl;
ret = pthread_create(&workerthread, 0, _entry_func3, (void*)&q);
if (ret != 0)
{
cerr << "Client Thread create2 failed.[" << errno << "]";
return EXIT_FAILURE;
}
// ±×³É ½Ã±×³Î ´ë±â
pause();
return EXIT_SUCCESS;
}