+class CoreExport SocketThread : public Thread
+{
+ ThreadQueueData queue;
+ ThreadSignalData signal;
+ protected:
+ /** Waits for an enqueue operation to complete
+ * You MUST hold the queue lock when you call this.
+ * It will be unlocked while you wait, and will be relocked
+ * before the function returns
+ */
+ void WaitForQueue()
+ {
+ queue.Wait();
+ }
+ public:
+ /** Notifies parent by making the SignalFD ready to read
+ * No requirements on locking
+ */
+ void NotifyParent();
+ SocketThread();
+ virtual ~SocketThread();
+ /** Lock queue.
+ */
+ void LockQueue()
+ {
+ queue.Lock();
+ }
+ /** Unlock queue.
+ */
+ void UnlockQueue()
+ {
+ queue.Unlock();
+ }
+ /** Unlock queue and send wakeup to worker
+ */
+ void UnlockQueueWakeup()
+ {
+ queue.Wakeup();
+ queue.Unlock();
+ }
+ virtual void SetExitFlag()
+ {
+ queue.Lock();
+ Thread::SetExitFlag();
+ queue.Wakeup();
+ queue.Unlock();
+ }
+
+ /**
+ * Called in the context of the parent thread after a notification
+ * has passed through the socket
+ */
+ virtual void OnNotify() = 0;