|
@@ -22,6 +22,24 @@ namespace oxygine
|
|
|
pthread_mutex_t& _mutex;
|
|
pthread_mutex_t& _mutex;
|
|
|
bool _locked;
|
|
bool _locked;
|
|
|
};
|
|
};
|
|
|
|
|
+ /*
|
|
|
|
|
+ class TDMessage
|
|
|
|
|
+ {
|
|
|
|
|
+ public:
|
|
|
|
|
+ TDMessage& withMSGID(int id) { msgid = id; return *this; }
|
|
|
|
|
+ TDMessage& withArgs(void* Arg1, void* Arg2 = 0) { arg1 = Arg1; arg2 = Arg2; return *this; }
|
|
|
|
|
+ TDMessage& withHighPriority() { hp = true; return *this; }
|
|
|
|
|
+ TDMessage& withReply() { reply = true; return *this; }
|
|
|
|
|
+
|
|
|
|
|
+ int msgid;
|
|
|
|
|
+ void* arg1;
|
|
|
|
|
+ void* arg2;
|
|
|
|
|
+ bool hp;
|
|
|
|
|
+ bool reply;
|
|
|
|
|
+
|
|
|
|
|
+ protected:
|
|
|
|
|
+ };*/
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**Messages Queue used for communication between threads*/
|
|
/**Messages Queue used for communication between threads*/
|
|
|
class ThreadDispatcher
|
|
class ThreadDispatcher
|
|
@@ -73,7 +91,7 @@ namespace oxygine
|
|
|
//blocking, sends message and waiting reply from other thread
|
|
//blocking, sends message and waiting reply from other thread
|
|
|
void* send(int msgid, void* arg1, void* arg2);
|
|
void* send(int msgid, void* arg1, void* arg2);
|
|
|
//blocking, sends callback and waiting until it is done
|
|
//blocking, sends callback and waiting until it is done
|
|
|
- void sendCallback(void* arg1, void* arg2, callback cb, void* cbData);
|
|
|
|
|
|
|
+ void sendCallback(void* arg1, void* arg2, callback cb, void* cbData, bool highPriority = false);
|
|
|
#ifndef __S3E__
|
|
#ifndef __S3E__
|
|
|
//blocking, sends callback and waiting until it is done
|
|
//blocking, sends callback and waiting until it is done
|
|
|
void sendCallback(const std::function<void()>&);
|
|
void sendCallback(const std::function<void()>&);
|
|
@@ -95,6 +113,12 @@ namespace oxygine
|
|
|
|
|
|
|
|
void reply(void* val);
|
|
void reply(void* val);
|
|
|
|
|
|
|
|
|
|
+ //void post(TDMessage&);
|
|
|
|
|
+ //void send(TDMessage&);
|
|
|
|
|
+
|
|
|
|
|
+ std::vector<message>& lockMessages();
|
|
|
|
|
+ void unlockMessages();
|
|
|
|
|
+
|
|
|
private:
|
|
private:
|
|
|
void _waitMessage();
|
|
void _waitMessage();
|
|
|
void _waitReply(int id);
|
|
void _waitReply(int id);
|
|
@@ -102,7 +126,7 @@ namespace oxygine
|
|
|
void _runCallbacks();
|
|
void _runCallbacks();
|
|
|
|
|
|
|
|
void _pushMessage(message&);
|
|
void _pushMessage(message&);
|
|
|
- void _pushMessageWaitReply(message&);
|
|
|
|
|
|
|
+ void _pushMessageWaitReply(message&, bool highPriority = false);
|
|
|
void _popMessage(message&);
|
|
void _popMessage(message&);
|
|
|
void _popMessageNoCB(message&);
|
|
void _popMessageNoCB(message&);
|
|
|
void _replyLast(void* val);
|
|
void _replyLast(void* val);
|
|
@@ -121,4 +145,11 @@ namespace oxygine
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
typedef ThreadDispatcher ThreadMessages;
|
|
typedef ThreadDispatcher ThreadMessages;
|
|
|
|
|
+
|
|
|
|
|
+ class ThreadDispatcher2
|
|
|
|
|
+ {
|
|
|
|
|
+ public:
|
|
|
|
|
+
|
|
|
|
|
+ protected:
|
|
|
|
|
+ };
|
|
|
}
|
|
}
|