summaryrefslogtreecommitdiff
path: root/toxcore/Messenger.c
diff options
context:
space:
mode:
authorCoren[m] <Break@Ocean>2013-10-02 16:38:54 +0200
committerCoren[m] <Break@Ocean>2013-10-02 16:38:54 +0200
commit2af0d43ce885880d8b8c63d0c2c4a2c56545f3d5 (patch)
treeff43ee6c709831948c991451d32613b58c7d75b1 /toxcore/Messenger.c
parentb9bffced7c75dc059ede6187cbefb773a2061e8f (diff)
Add tox_wait() for socket, allow tox.h include in tox.c
tox.*, Messenger.*, network.*; - new function tox_wait() => waitMessenger() => networking_wait(): - waits for a given amount of time for any sort of socket activity - mustn't change anything inside, mustn't poll or do other stuff - the point is to be able to call this asynchronously from a second thread - the outside shall follow up with an immediate tox_do() when there's socket activity tox.*: - allow inclusion of tox.h into tox.c, ensuring that the outside interface and the internal always match util.c: - squished a few warnings about questionable format strings
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r--toxcore/Messenger.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c
index c8d69494..54ee6cce 100644
--- a/toxcore/Messenger.c
+++ b/toxcore/Messenger.c
@@ -26,6 +26,7 @@
26#endif 26#endif
27 27
28#include "Messenger.h" 28#include "Messenger.h"
29#include "network.h"
29#include "util.h" 30#include "util.h"
30 31
31#define MIN(a,b) (((a)<(b))?(a):(b)) 32#define MIN(a,b) (((a)<(b))?(a):(b))
@@ -1388,6 +1389,21 @@ void doMessenger(Messenger *m)
1388#endif 1389#endif
1389} 1390}
1390 1391
1392/*
1393 * Waits for something to happen on the socket for up to milliseconds milliseconds
1394 * *** Function MUSTN'T poll. ***
1395 * The function mustn't modify anything at all, so it can be called completely
1396 * asynchronously without any worry.
1397 *
1398 * returns 0 if the timeout was reached
1399 * returns 1 if there is socket activity (i.e. tox_do() should be called)
1400 *
1401 */
1402int waitMessenger(Messenger *m, uint16_t milliseconds)
1403{
1404 return networking_wait(m->net, milliseconds);
1405};
1406
1391/* return size of the messenger data (for saving) */ 1407/* return size of the messenger data (for saving) */
1392uint32_t Messenger_size_old(Messenger *m) 1408uint32_t Messenger_size_old(Messenger *m)
1393{ 1409{