Replaced tox_wait* functions with tox_do_run_interval().

Build system fixes.
This commit is contained in:
irungentoo 2014-05-30 13:20:36 -04:00
parent 6b152d2bac
commit 0e814904e4
No known key found for this signature in database
GPG Key ID: 10349DC9BED89E98
5 changed files with 24 additions and 53 deletions

View File

@ -7,5 +7,5 @@ Name: libtoxcore
Description: Tox protocol library
Requires:
Version: @PACKAGE_VERSION@
Libs: @NACL_OBJECTS_PKGCONFIG@ -L${libdir} @NACL_LDFLAGS@ -ltoxcore @NACL_LIBS@ @LIBS@
Libs: @NACL_OBJECTS_PKGCONFIG@ -L${libdir} @NACL_LDFLAGS@ -ltoxcore @NACL_LIBS@ @LIBS@ @MATH_LDFLAGS@
Cflags: -I${includedir}

View File

@ -13,7 +13,9 @@ nTox_LDADD = $(LIBSODIUM_LDFLAGS) \
$(NAC_LDFLAGS) \
libtoxcore.la \
$(LIBSODIUM_LIBS) \
$(NACL_OBJECTS) \
$(NACL_LIBS) \
$(MATH_LDFLAGS) \
$(NCURSES_LIBS) \
$(WINSOCK2_LIBS)
endif
@ -51,6 +53,7 @@ Messenger_test_LDADD = $(LIBSODIUM_LDFLAGS) \
$(LIBSODIUM_LIBS) \
$(NACL_OBJECTS) \
$(NACL_LIBS) \
$(MATH_LDFLAGS) \
$(WINSOCK2_LIBS)
@ -85,6 +88,7 @@ tox_sync_LDADD = $(LIBSODIUM_LDFLAGS) \
$(LIBSODIUM_LIBS) \
$(NACL_OBJECTS) \
$(NACL_LIBS) \
$(MATH_LDFLAGS) \
$(WINSOCK2_LIBS)
endif

View File

@ -542,6 +542,7 @@ void line_eval(Tox *m, char *line)
} else if (inpt_command == 'q') { //exit
save_data(m);
endwin();
tox_kill(m);
exit(EXIT_SUCCESS);
} else if (inpt_command == 'c') { //set conversation partner
if (line[2] == 'r') {
@ -1274,17 +1275,8 @@ int main(int argc, char *argv[])
}
}
if (numfilesenders > 0)
// during file transfer wasting cpu cycles is almost unavoidable
c_sleep(1);
else {
if (pollok && (tox_wait_prepare(m, data) == 1)) {
/* 250ms is more than fast enough in "regular" mode */
tox_wait_execute(data, 0, 100000);
tox_wait_cleanup(m, data);
} else
c_sleep(25);
}
c_sleep(tox_do_run_interval(m));
send_filesenders(m);
tox_do(m);

View File

@ -782,6 +782,16 @@ int tox_isconnected(Tox *tox)
return DHT_isconnected(m->dht);
}
/* Return the optimal interval in milliseconds between tox_do() calls.
* This function should be called after every tox_do() call for best performance.
*/
uint32_t tox_do_run_interval(Tox *tox)
{
Messenger *m = tox;
//TODO
return 10;
}
/* Run this at startup.
*
* return allocated instance of tox on success.

View File

@ -644,48 +644,13 @@ Tox *tox_new(uint8_t ipv6enabled);
* Free all datastructures. */
void tox_kill(Tox *tox);
/* The main loop that needs to be run at least 20 times per second. */
void tox_do(Tox *tox);
/*
* tox_wait_data_size():
*
* returns a size of data buffer to allocate. the size is constant.
*
* tox_wait_prepare(): function should be called under lock every time we want to call tox_wait_execute()
* Prepares the data required to call tox_wait_execute() asynchronously
*
* data[] should be of at least tox_wait_data_size() size and it's reserved and kept by the caller
* Use that data[] to call tox_wait_execute()
*
* returns 1 on success
* returns 0 if data was NULL
*
*
* tox_wait_execute(): function can be called asynchronously
* Waits for something to happen on the socket for up to seconds seconds and mircoseconds microseconds.
* mircoseconds should be between 0 and 999999.
* If you set either or both seconds and microseconds to negatives, it will block indefinetly until there
* is an activity.
*
* returns 2 if there is socket activity (i.e. tox_do() should be called)
* returns 1 if the timeout was reached (tox_do() should be called anyway. it's advised to call it at least
* once per second)
* returns 0 if data was NULL
*
*
* tox_wait_cleanup(): function should be called under lock, every time tox_wait_execute() finishes
* Stores results from tox_wait_execute().
*
* returns 1 on success
* returns 0 if data was NULL
*
/* Return the optimal interval in milliseconds between tox_do() calls.
* This function should be called after every tox_do() call for best performance.
*/
size_t tox_wait_data_size();
int tox_wait_prepare(Tox *tox, uint8_t *data);
int tox_wait_execute(uint8_t *data, long seconds, long microseconds);
int tox_wait_cleanup(Tox *tox, uint8_t *data);
uint32_t tox_do_run_interval(Tox *tox);
/* The main loop that needs to be run in intervals of tox_do_run_interval() ms. */
void tox_do(Tox *tox);
/* SAVING AND LOADING FUNCTIONS: */