S R T B H P N

BlockingQueue.h BlockingQueue.cpp BlockingQueue.txt Code folder

This code illustrates how Packages should be structured
and is also a good example of a template class.
We will find BlockingQueue to be very useful when writing multi-threaded code.

    
  Demonstrating C++11 Blocking Queue
 ====================================
   main enQing msg#0
  thread deQed msg#0
   main enQing msg#1
   main enQing msg#2
  thread deQed msg#1
   main enQing msg#3
   main enQing msg#4
   main enQing msg#5
  thread deQed msg#2
   main enQing msg#6
   main enQing msg#7
   main enQing msg#8
  thread deQed msg#3
   main enQing msg#9
   main enQing msg#10
  thread deQed msg#4
   main enQing msg#11
   main enQing msg#12
   main enQing msg#13
  thread deQed msg#5
   main enQing msg#14
  thread deQed msg#6
  thread deQed msg#7
  thread deQed msg#8
  thread deQed msg#9
  thread deQed msg#10
  thread deQed msg#11
  thread deQed msg#12
  thread deQed msg#13
  thread deQed msg#14
  thread deQed quit
  Making move copy of BlockingQueue
 -----------------------------------
  before move:
    q.size() = 1
    q.front() = test
  after move:
    q2.size() = 1
    q.size() = 0
    q2 element = test
  Move assigning state of BlockingQueue
 ---------------------------------------
  before move:
    q.size() = 1
    q.front() = test
  after move:
    q.size() = 0
    q3.size() = 1
    q3 element = test

Press any key to continue . . .