he following code is the simplest example of use.
Line 07: Create a queue.
Line 09: Create a piece of data.
Line 10: Push the piece of data into the queue.
Line 11: Pop the piece of data from the queue.
01\
#include
<NonBlockingQueue.hpp>
02\
typedef
std::string TestData;
02a\
typedef
ots::scheduler::NonBlockingQueue<TestData> TestQueue;
02b\
typedef
TestQueue::Node TestNode;
03\
bool
simpleTest()
04\
{
07\
TestQueue
queue;
08\
const
std::string s("Hello!");
09\
TestNode
node(s);
10\
queue.push(node);
11\
volatile
TestNode& n=queue.pop();
12\
return
&node==&n;
13\
}
|