mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Replaced tox_wait* functions with tox_do_run_interval().
Build system fixes.
This commit is contained in:
parent
6b152d2bac
commit
0e814904e4
|
@ -7,5 +7,5 @@ Name: libtoxcore
|
||||||
Description: Tox protocol library
|
Description: Tox protocol library
|
||||||
Requires:
|
Requires:
|
||||||
Version: @PACKAGE_VERSION@
|
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}
|
Cflags: -I${includedir}
|
||||||
|
|
|
@ -13,7 +13,9 @@ nTox_LDADD = $(LIBSODIUM_LDFLAGS) \
|
||||||
$(NAC_LDFLAGS) \
|
$(NAC_LDFLAGS) \
|
||||||
libtoxcore.la \
|
libtoxcore.la \
|
||||||
$(LIBSODIUM_LIBS) \
|
$(LIBSODIUM_LIBS) \
|
||||||
|
$(NACL_OBJECTS) \
|
||||||
$(NACL_LIBS) \
|
$(NACL_LIBS) \
|
||||||
|
$(MATH_LDFLAGS) \
|
||||||
$(NCURSES_LIBS) \
|
$(NCURSES_LIBS) \
|
||||||
$(WINSOCK2_LIBS)
|
$(WINSOCK2_LIBS)
|
||||||
endif
|
endif
|
||||||
|
@ -51,6 +53,7 @@ Messenger_test_LDADD = $(LIBSODIUM_LDFLAGS) \
|
||||||
$(LIBSODIUM_LIBS) \
|
$(LIBSODIUM_LIBS) \
|
||||||
$(NACL_OBJECTS) \
|
$(NACL_OBJECTS) \
|
||||||
$(NACL_LIBS) \
|
$(NACL_LIBS) \
|
||||||
|
$(MATH_LDFLAGS) \
|
||||||
$(WINSOCK2_LIBS)
|
$(WINSOCK2_LIBS)
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,6 +88,7 @@ tox_sync_LDADD = $(LIBSODIUM_LDFLAGS) \
|
||||||
$(LIBSODIUM_LIBS) \
|
$(LIBSODIUM_LIBS) \
|
||||||
$(NACL_OBJECTS) \
|
$(NACL_OBJECTS) \
|
||||||
$(NACL_LIBS) \
|
$(NACL_LIBS) \
|
||||||
|
$(MATH_LDFLAGS) \
|
||||||
$(WINSOCK2_LIBS)
|
$(WINSOCK2_LIBS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -542,6 +542,7 @@ void line_eval(Tox *m, char *line)
|
||||||
} else if (inpt_command == 'q') { //exit
|
} else if (inpt_command == 'q') { //exit
|
||||||
save_data(m);
|
save_data(m);
|
||||||
endwin();
|
endwin();
|
||||||
|
tox_kill(m);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
} else if (inpt_command == 'c') { //set conversation partner
|
} else if (inpt_command == 'c') { //set conversation partner
|
||||||
if (line[2] == 'r') {
|
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(tox_do_run_interval(m));
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
send_filesenders(m);
|
send_filesenders(m);
|
||||||
tox_do(m);
|
tox_do(m);
|
||||||
|
|
|
@ -782,6 +782,16 @@ int tox_isconnected(Tox *tox)
|
||||||
return DHT_isconnected(m->dht);
|
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.
|
/* Run this at startup.
|
||||||
*
|
*
|
||||||
* return allocated instance of tox on success.
|
* return allocated instance of tox on success.
|
||||||
|
|
|
@ -644,48 +644,13 @@ Tox *tox_new(uint8_t ipv6enabled);
|
||||||
* Free all datastructures. */
|
* Free all datastructures. */
|
||||||
void tox_kill(Tox *tox);
|
void tox_kill(Tox *tox);
|
||||||
|
|
||||||
/* The main loop that needs to be run at least 20 times per second. */
|
/* Return the optimal interval in milliseconds between tox_do() calls.
|
||||||
void tox_do(Tox *tox);
|
* This function should be called after every tox_do() call for best performance.
|
||||||
|
|
||||||
/*
|
|
||||||
* 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
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
size_t tox_wait_data_size();
|
uint32_t tox_do_run_interval(Tox *tox);
|
||||||
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);
|
|
||||||
|
|
||||||
|
/* 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: */
|
/* SAVING AND LOADING FUNCTIONS: */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user