diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2013-03-22 20:48:17 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2013-03-22 20:48:17 +0100 |
commit | 3089c4bbc10e98d18f43e8a70e7a3d0c0eaf0900 (patch) | |
tree | c6f985472c05372417ecd4a861f6c2f346b63fd3 /faceAPI/lockfree.h | |
parent | 3e1515e88c6f750c193ed9b9908d8a9c09e5b025 (diff) |
Downcase. PLEASE TURN OFF IGNORING CASE IN GIT CONFIG!!!
.git/config:
[core]
ignorecase = false
Diffstat (limited to 'faceAPI/lockfree.h')
-rw-r--r-- | faceAPI/lockfree.h | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/faceAPI/lockfree.h b/faceAPI/lockfree.h deleted file mode 100644 index ce7d2a64..00000000 --- a/faceAPI/lockfree.h +++ /dev/null @@ -1,65 +0,0 @@ -//lock free queue template class by Herb Sutter
-//Dr Dobbs Journal article http://www.drdobbs.com/cpp/210604448;jsessionid=OQGQPSMNL4X4XQE1GHPSKH4ATMY32JVN?pgno=1
-
-template <typename T> class LockFreeQueue
-{
-private:
- struct Node
- {
- Node( T val ) : value(val), next(nullptr) { }
- T value;
- Node* next;
- };
-
- Node* first; // for producer only
- Node* divider, last; // shared
-
- //not working in VC2008
- //atomic<Node*> divider, last; // shared
-
-public:
- LockFreeQueue()
- {
- // add dummy separator
- first = divider = last = new Node( T() );
- }
-
- ~LockFreeQueue()
- {
- while( first != nullptr )
- {
- // release the list
- Node* tmp = first;
- first = tmp->next;
- delete tmp;
- }
- }
-
- void Produce( const T& t )
- {
- last->next = new Node(t); // add the new item
- last = last->next; // publish it
-
- while( first != divider )
- {
- // trim unused nodes
- Node* tmp = first;
- first = first->next;
- delete tmp;
- }
- }
-
- bool Consume( T& result )
- {
- if( divider != last )
- {
- // if queue is nonempty
- result = divider->next->value; // copy it back
- divider = divider->next; // publish that we took it
- return true; // and report success
- }
-
- return false; // else report empty
- }
-};
-
|