Re: [Boost-bugs] [Boost C++ Libraries] #12394: boost::lockfree::queue with gcc-4.6 + optimization

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #12394: boost::lockfree::queue with gcc-4.6 + optimization
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-08-15 15:23:45


#12394: boost::lockfree::queue with gcc-4.6 + optimization
-------------------------------+-----------------------------
  Reporter: ygabay@… | Owner: timblechmann
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: lockfree
   Version: Boost 1.58.0 | Severity: Problem
Resolution: | Keywords: lockfree, queue
-------------------------------+-----------------------------

Comment (by anonymous):

 minor compilation issue in the test program. here is updated version:



 {{{
 #include <string>
 #include <deque>
 #include <cstdio>

 #include <boost/lockfree/queue.hpp>
 #include <cassert>
 #include <iostream>

 struct SemTask
 {
  int x;
 };
 boost::lockfree::queue<SemTask * > queue(1);

 void* runner(void* arg)
 {
     std::cout << '.' << std::endl;
     while (true)
     {
       SemTask * task = new SemTask();
       assert(queue.push(task));
       assert(queue.pop(task));
       delete task;
     }
     return NULL;
 }

 int main(int argc, char** argv)
 {
   assert(queue.is_lock_free());
   #define NUM_THRD 2
   pthread_t inc_x_thread[NUM_THRD];

   for (int i = 0; i < NUM_THRD; ++i) {
     if(pthread_create(&inc_x_thread[i], NULL, runner, NULL)) {
       fprintf(stderr, "Error creating thread\n");
       return -1;
     }
   }

   for (int i = 0; i < NUM_THRD; ++i) {
     if(pthread_join(inc_x_thread[i], NULL)) {
       fprintf(stderr, "Error joining thread\n");
       return -1;
     }
   }

   return 0;
 }

 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/12394#comment:1>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:20 UTC