Dedicated getline() thread on windows for async reading of stdin.
This commit is contained in:
parent
77d363fa0a
commit
09146d7e71
|
@ -1,5 +1,12 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# all working at revision 5346
|
# all working at revision 5346
|
||||||
|
if [ "$1" == "win" ]; then
|
||||||
|
echo "building windows then pushing to killer3"
|
||||||
|
bjam gcc-win32 "cflags=-DTORRENT_USE_I2P=0 -DBOOST_NO_EXCEPTIONS=1" link=static boost=source target-os=windows encryption=tommath variant=release geoip=off logging=none threadapi=win32 iconv=off deprecated-functions=off java_client
|
||||||
|
i586-mingw32msvc-strip bin/gcc-mingw-win32/release/boost-source/deprecated-functions-off/iconv-off/link-static/target-os-windows/threadapi-win32/threading-multi/java_client.exe
|
||||||
|
scp bin/gcc-mingw-win32/release/boost-source/deprecated-functions-off/iconv-off/link-static/target-os-windows/threadapi-win32/threading-multi/java_client.exe mopar@killer3:/home/mopar/java_client/java_client.win32.exe
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
if [ "$1" == "clean" ]; then
|
if [ "$1" == "clean" ]; then
|
||||||
echo "cleaning previous builds"
|
echo "cleaning previous builds"
|
||||||
rm -rf ./bin/ /home/mopar/biggerdaddy/libtorrent/libtorrent-rasterbar-trunk/trunk/bin /home/mopar/biggerdaddy/libtorrent/boost_1_46_0/bin.v2/
|
rm -rf ./bin/ /home/mopar/biggerdaddy/libtorrent/libtorrent-rasterbar-trunk/trunk/bin /home/mopar/biggerdaddy/libtorrent/boost_1_46_0/bin.v2/
|
||||||
|
|
|
@ -79,42 +79,37 @@ void debug( const char* format, ... ) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <conio.h>
|
#include <process.h>
|
||||||
|
|
||||||
|
std::string thread_char;
|
||||||
|
bool thread_running = false;
|
||||||
|
|
||||||
|
void Thread( void* pParams )
|
||||||
|
{
|
||||||
|
// waits for enter to be pressed, doesn't include newline
|
||||||
|
//std::cin >> thread_char;
|
||||||
|
std::getline(std::cin, thread_char);
|
||||||
|
thread_running = false;
|
||||||
|
}
|
||||||
|
|
||||||
bool sleep_and_input(char* c, int sleep)
|
bool sleep_and_input(char* c, int sleep)
|
||||||
{
|
{
|
||||||
void *input = GetStdHandle(STD_INPUT_HANDLE);
|
if(thread_running){
|
||||||
int wait_result = WaitForSingleObject(input, sleep*1000);
|
Sleep(sleep*1000);
|
||||||
if (wait_result == WAIT_TIMEOUT) {
|
|
||||||
/* it timed out - no input */
|
|
||||||
debug("wait timed out, no input");
|
|
||||||
return false;
|
return false;
|
||||||
} else if (wait_result == WAIT_OBJECT_0){
|
}
|
||||||
/* it signaled in time - input available */
|
if(!thread_char.empty()){
|
||||||
*c = _getch();
|
//strncpy(c, &thread_char, 1);
|
||||||
|
thread_char.copy(c,1,0);
|
||||||
|
thread_char.clear();
|
||||||
|
// we don't want to start the thread again here, since after we return from
|
||||||
|
// this function we might want to read from stdin someplace else
|
||||||
return true;
|
return true;
|
||||||
} else if (wait_result == WAIT_FAILED || wait_result == WAIT_ABANDONED) {
|
|
||||||
/* some shit went wrong */
|
|
||||||
debug("somethting went wrong with wait");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
thread_running = true;
|
||||||
|
_beginthread(Thread, 0, NULL);
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
/*
|
|
||||||
bool sleep_and_input(char* c, int sleep)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < sleep * 2; ++i)
|
|
||||||
{
|
|
||||||
if (_kbhit())
|
|
||||||
{
|
|
||||||
*c = _getch();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Sleep(500);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
#else
|
#else
|
||||||
#define EXE ""
|
#define EXE ""
|
||||||
|
|
||||||
|
@ -193,7 +188,7 @@ void signal_callback_handler(int signum){
|
||||||
|
|
||||||
const std::string tag_delim(": ");
|
const std::string tag_delim(": ");
|
||||||
|
|
||||||
int die_timeout = 10;
|
int die_timeout = 5;
|
||||||
int allocation_mode = libtorrent::storage_mode_sparse;
|
int allocation_mode = libtorrent::storage_mode_sparse;
|
||||||
//float preferred_ratio = 0.f;
|
//float preferred_ratio = 0.f;
|
||||||
float preferred_ratio = 1.f;
|
float preferred_ratio = 1.f;
|
||||||
|
@ -469,7 +464,7 @@ void fatal_error(const char* error = 0){
|
||||||
" seconds between screen refreshes, default 1.\n"
|
" seconds between screen refreshes, default 1.\n"
|
||||||
" -q forces the client to print every -F seconds, instead of\n"
|
" -q forces the client to print every -F seconds, instead of\n"
|
||||||
" only when with 'r' is pressed\n"
|
" only when with 'r' is pressed\n"
|
||||||
" -e <timeout> Waits (timeout * -F) and quits if 'r' is not pressed, default 10.\n"
|
" -e <timeout> Waits (timeout * -F) and quits if 'r' is not pressed, default 5.\n"
|
||||||
" -n announce to trackers in all tiers\n"
|
" -n announce to trackers in all tiers\n"
|
||||||
" -t announce to all trackers\n"
|
" -t announce to all trackers\n"
|
||||||
" -h allow multiple connections from the same IP\n"
|
" -h allow multiple connections from the same IP\n"
|
||||||
|
|
|
@ -25,7 +25,7 @@ package org.moparscape.res.impl;
|
||||||
*/
|
*/
|
||||||
public class BTDownloaderCRCs {
|
public class BTDownloaderCRCs {
|
||||||
|
|
||||||
private static final long[] crcs = new long[]{1388496215L /*-java_client.linux.x86*/, 3350772002L /*-java_client.osx.i386*/, 1847997845L /*-java_client.osx.ppc*/, 3985172341L /*-java_client.win32.exe*/};
|
private static final long[] crcs = new long[]{3304301470L /*-java_client.linux.x86*/, 21879546L /*-java_client.osx.i386*/, 4003616367L /*-java_client.osx.ppc*/, 3354565870L /*-java_client.win32.exe*/};
|
||||||
|
|
||||||
public static final int LINUX = 0;
|
public static final int LINUX = 0;
|
||||||
public static final int OSX386 = 1;
|
public static final int OSX386 = 1;
|
||||||
|
|
Loading…
Reference in New Issue