Changeset 3062


Ignore:
Timestamp:
Jul 2, 2013, 5:08:42 AM (8 years ago)
Author:
Peter
Message:

implement copy and assignment (compiler generated does not compile sinc emutex is not copyable)

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/queue.cc

    r3057 r3062  
    7373  workers.join_all();
    7474
    75   std::cerr << "OK\n";
    76   return 0;
     75  Queue<std::string> queue2(queue);
     76
     77  queue2 = queue;
     78
     79  return suite.return_value();
    7780}
  • trunk/yat/utility/Queue.h

    r3061 r3062  
    2222
    2323#include <deque>
     24#include <utility>
    2425
    2526namespace theplu {
     
    5859    */
    5960    typedef typename std::deque<T>::size_type size_type;
     61
     62    /**
     63       \brief Create a Queue with no elements
     64    */
     65    Queue(void) {}
     66
     67    /**
     68       \brief Create a Queue with no elements
     69
     70       \note is not thread safe
     71    */
     72    Queue(const Queue& other) : q_(other.q_) {}
    6073
    6174    /**
     
    129142    } // lock is released here
    130143
     144
     145    /**
     146       \brief assignment operator
     147
     148       \note is not thread safe
     149     */
     150    Queue& operator=(const Queue& lhs)
     151    {
     152      q_ = lhs.q_;
     153      return *this;
     154    }
     155
    131156  private:
    132157    std::deque<T> q_;
    133158    mutable boost::mutex mutex_;
    134159    boost::condition_variable condition_;
    135 
    136     // Using compiler generated (not thread safe) copy and assignment
    137     //Queue(const Queue&);
    138     //Queue& operator=(const Queue&);
    139160  };
    140161
Note: See TracChangeset for help on using the changeset viewer.