summaryrefslogtreecommitdiff
path: root/toxcore
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore')
-rw-r--r--toxcore/tox.c10
-rw-r--r--toxcore/tox.h45
2 files changed, 15 insertions, 40 deletions
diff --git a/toxcore/tox.c b/toxcore/tox.c
index 884223ff..f9df7860 100644
--- a/toxcore/tox.c
+++ b/toxcore/tox.c
@@ -782,6 +782,16 @@ int tox_isconnected(Tox *tox)
782 return DHT_isconnected(m->dht); 782 return DHT_isconnected(m->dht);
783} 783}
784 784
785/* Return the optimal interval in milliseconds between tox_do() calls.
786 * This function should be called after every tox_do() call for best performance.
787 */
788uint32_t tox_do_run_interval(Tox *tox)
789{
790 Messenger *m = tox;
791 //TODO
792 return 10;
793}
794
785/* Run this at startup. 795/* Run this at startup.
786 * 796 *
787 * return allocated instance of tox on success. 797 * return allocated instance of tox on success.
diff --git a/toxcore/tox.h b/toxcore/tox.h
index f54d113e..e2207336 100644
--- a/toxcore/tox.h
+++ b/toxcore/tox.h
@@ -644,48 +644,13 @@ Tox *tox_new(uint8_t ipv6enabled);
644 * Free all datastructures. */ 644 * Free all datastructures. */
645void tox_kill(Tox *tox); 645void tox_kill(Tox *tox);
646 646
647/* The main loop that needs to be run at least 20 times per second. */ 647/* Return the optimal interval in milliseconds between tox_do() calls.
648void tox_do(Tox *tox); 648 * This function should be called after every tox_do() call for best performance.
649
650/*
651 * tox_wait_data_size():
652 *
653 * returns a size of data buffer to allocate. the size is constant.
654 *
655 * tox_wait_prepare(): function should be called under lock every time we want to call tox_wait_execute()
656 * Prepares the data required to call tox_wait_execute() asynchronously
657 *
658 * data[] should be of at least tox_wait_data_size() size and it's reserved and kept by the caller
659 * Use that data[] to call tox_wait_execute()
660 *
661 * returns 1 on success
662 * returns 0 if data was NULL
663 *
664 *
665 * tox_wait_execute(): function can be called asynchronously
666 * Waits for something to happen on the socket for up to seconds seconds and mircoseconds microseconds.
667 * mircoseconds should be between 0 and 999999.
668 * If you set either or both seconds and microseconds to negatives, it will block indefinetly until there
669 * is an activity.
670 *
671 * returns 2 if there is socket activity (i.e. tox_do() should be called)
672 * returns 1 if the timeout was reached (tox_do() should be called anyway. it's advised to call it at least
673 * once per second)
674 * returns 0 if data was NULL
675 *
676 *
677 * tox_wait_cleanup(): function should be called under lock, every time tox_wait_execute() finishes
678 * Stores results from tox_wait_execute().
679 *
680 * returns 1 on success
681 * returns 0 if data was NULL
682 *
683 */ 649 */
684size_t tox_wait_data_size(); 650uint32_t tox_do_run_interval(Tox *tox);
685int tox_wait_prepare(Tox *tox, uint8_t *data);
686int tox_wait_execute(uint8_t *data, long seconds, long microseconds);
687int tox_wait_cleanup(Tox *tox, uint8_t *data);
688 651
652/* The main loop that needs to be run in intervals of tox_do_run_interval() ms. */
653void tox_do(Tox *tox);
689 654
690/* SAVING AND LOADING FUNCTIONS: */ 655/* SAVING AND LOADING FUNCTIONS: */
691 656