Index: trunk/Mars/mcore/Queue.h
===================================================================
--- trunk/Mars/mcore/Queue.h	(revision 17226)
+++ trunk/Mars/mcore/Queue.h	(revision 17227)
@@ -6,11 +6,17 @@
 #include <condition_variable>
 
-template<class T>
+// The second template argument must support:
+//    iterator it = begin();   // get the next element to be processed
+//    erase(it);               // erase the processed element from the queue
+//    push_back();             // add a new element to the queue
+//    emplace_back();          // emplace a new element to the queue
+//    splice();                // used to efficiently implement post with mutex
+
+template<class T, class List=std::list<T>>
 class Queue
 {
     size_t fSize;                 // Only necessary for before C++11
-    bool   fSort;                 // Sort the list before processing
-
-    std::list<T> fList;
+
+    List fList;
 
     std::mutex fMutex;             // Mutex needed for the conditional
@@ -54,5 +60,5 @@
 
             // If thread got just woken up, move back the state to kRun
-            if (fState == kTrigger)
+            if (fState==kTrigger)
                 fState = kRun;
 
@@ -66,5 +72,5 @@
 
             // get the first entry from the (sorted) list
-            const auto it = fSort ? min_element(fList.begin(), fList.end()) : fList.begin();
+            const auto it = fList.begin();
 
             // Theoretically, we can loose a signal here, but this is
@@ -76,5 +82,5 @@
             // been posted (or the number of events in the queue has
             // changed)  [allowed>0], in the case processing was
-            // successfull [alloed==0], the next event will be processed
+            // successfull [allowed==0], the next event will be processed
             // immediately.
             if (!fCallback || !fCallback(*it))
@@ -88,8 +94,5 @@
                 continue;
 
-            if (fSort)
-                fList.erase(it);
-            else
-                fList.pop_front() ;
+            fList.erase(it);
 
             fSize--;
@@ -105,5 +108,5 @@
 
 public:
-    Queue(const callback &f, bool sort=false, bool startup=true) : fSize(0), fSort(sort), fState(kIdle), fCallback(f)
+    Queue(const callback &f, bool startup=true) : fSize(0), fState(kIdle), fCallback(f)
     {
         if (startup)
@@ -111,12 +114,11 @@
     }
 
-    Queue(const Queue<T>& q) : fSize(0), fSort(q.fSort), fState(kIdle), fCallback(q.fCallback)
-    {
-    }
-
-    Queue<T>& operator = (const Queue<T>& q)
+    Queue(const Queue<T,List>& q) : fSize(0), fState(kIdle), fCallback(q.fCallback)
+    {
+    }
+
+    Queue<T,List>& operator = (const Queue<T,List>& q)
     {
         fSize     = 0;
-        fSort     = q.fSort;
         fState    = kIdle;
         fCallback = q.fCallback;
@@ -229,7 +231,7 @@
 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
-    bool move(std::list<T>&& x, typename std::list<T>::iterator i)
+    bool move(List&& x, typename List::iterator i)
 #else
-    bool move(std::list<T>& x, typename std::list<T>::iterator i)
+    bool move(List& x, typename List::iterator i)
 #endif
     {
@@ -247,5 +249,5 @@
 
 #ifdef __GXX_EXPERIMENTAL_CXX0X__
-    bool move(std::list<T>& x, typename std::list<T>::iterator i) { return move(std::move(x), i); }
+    bool move(List& x, typename List::iterator i) { return move(std::move(x), i); }
 #endif
 
