fixed bugs in mutex protection in sio.
added qse_open_stdsios_with_flags
This commit is contained in:
		@ -401,6 +401,10 @@ QSE_EXPORT int qse_open_stdsios (
 | 
				
			|||||||
	void
 | 
						void
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					QSE_EXPORT int qse_open_stdsios_with_flags (
 | 
				
			||||||
 | 
						int flags
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QSE_EXPORT void qse_close_stdsios (
 | 
					QSE_EXPORT void qse_close_stdsios (
 | 
				
			||||||
	void
 | 
						void
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 | 
				
			|||||||
@ -456,8 +456,6 @@ static qse_ssize_t putwc_no_mutex (qse_sio_t* sio, qse_wchar_t c)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	qse_ssize_t n;
 | 
						qse_ssize_t n;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	LOCK (sio);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	sio->errnum = QSE_SIO_ENOERR;
 | 
						sio->errnum = QSE_SIO_ENOERR;
 | 
				
			||||||
#if defined(__OS2__)
 | 
					#if defined(__OS2__)
 | 
				
			||||||
	if (c == QSE_WT('\n') && (sio->status & STATUS_LINE_BREAK))
 | 
						if (c == QSE_WT('\n') && (sio->status & STATUS_LINE_BREAK))
 | 
				
			||||||
@ -470,7 +468,6 @@ static qse_ssize_t putwc_no_mutex (qse_sio_t* sio, qse_wchar_t c)
 | 
				
			|||||||
	if (n <= -1 && sio->errnum == QSE_SIO_ENOERR) 
 | 
						if (n <= -1 && sio->errnum == QSE_SIO_ENOERR) 
 | 
				
			||||||
		sio->errnum = tio_errnum_to_sio_errnum (&sio->tio.io);
 | 
							sio->errnum = tio_errnum_to_sio_errnum (&sio->tio.io);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	UNLOCK (sio);
 | 
					 | 
				
			||||||
	return n;
 | 
						return n;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -875,15 +872,20 @@ static qse_sio_t* sio_stdout = QSE_NULL;
 | 
				
			|||||||
static qse_sio_t* sio_stderr = QSE_NULL;
 | 
					static qse_sio_t* sio_stderr = QSE_NULL;
 | 
				
			||||||
/* TODO: add sio_stdin, qse_getmbs, etc */
 | 
					/* TODO: add sio_stdin, qse_getmbs, etc */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int qse_open_stdsios (void)
 | 
					int qse_open_stdsios ()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return qse_open_stdsios_with_flags (QSE_SIO_LINEBREAK | QSE_SIO_REENTRANT);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int qse_open_stdsios_with_flags (int flags)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (sio_stdout == QSE_NULL)
 | 
						if (sio_stdout == QSE_NULL)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		sio_stdout = qse_sio_openstd (QSE_MMGR_GETDFL(), 0, QSE_SIO_STDOUT, QSE_SIO_LINEBREAK | QSE_SIO_REENTRANT);
 | 
							sio_stdout = qse_sio_openstd (QSE_MMGR_GETDFL(), 0, QSE_SIO_STDOUT, flags);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (sio_stderr == QSE_NULL)
 | 
						if (sio_stderr == QSE_NULL)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		sio_stderr = qse_sio_openstd (QSE_MMGR_GETDFL(), 0, QSE_SIO_STDERR, QSE_SIO_LINEBREAK | QSE_SIO_REENTRANT);
 | 
							sio_stderr = qse_sio_openstd (QSE_MMGR_GETDFL(), 0, QSE_SIO_STDERR, flags);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (sio_stdout == QSE_NULL || sio_stderr == QSE_NULL) 
 | 
						if (sio_stdout == QSE_NULL || sio_stderr == QSE_NULL) 
 | 
				
			||||||
@ -1031,9 +1033,11 @@ qse_ssize_t qse_errputwcsf (const qse_wchar_t* fmt, ...)
 | 
				
			|||||||
	fo.conv = mbs_to_wcs;
 | 
						fo.conv = mbs_to_wcs;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	va_start (ap, fmt);
 | 
						va_start (ap, fmt);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	LOCK (sio_stderr);
 | 
						LOCK (sio_stderr);
 | 
				
			||||||
	x = qse_wfmtout(fmt, &fo, ap);
 | 
						x = qse_wfmtout(fmt, &fo, ap);
 | 
				
			||||||
	UNLOCK (sio_stderr);
 | 
						UNLOCK (sio_stderr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	va_end (ap);
 | 
						va_end (ap);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return (x <= -1)? -1: fo.count;
 | 
						return (x <= -1)? -1: fo.count;
 | 
				
			||||||
 | 
				
			|||||||
@ -3,17 +3,16 @@
 | 
				
			|||||||
#include <qse/si/sio.h>
 | 
					#include <qse/si/sio.h>
 | 
				
			||||||
#include <qse/cmn/mem.h>
 | 
					#include <qse/cmn/mem.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <locale.h>
 | 
					#include <locale.h>
 | 
				
			||||||
#if defined(_WIN32)
 | 
					#if defined(_WIN32)
 | 
				
			||||||
#	include <windows.h>
 | 
					#	include <windows.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <unistd.h>
 | 
					 | 
				
			||||||
#include <signal.h>
 | 
					#include <signal.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int g_stopreq = 0;
 | 
					static int g_stopreq = 0;
 | 
				
			||||||
 | 
					static qse_ntime_t sleep_interval = { 1, 0 };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct thr_xtn_t
 | 
					struct thr_xtn_t
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -34,7 +33,7 @@ static int thr_func (qse_thr_t* thr, void* ctx)
 | 
				
			|||||||
		qse_printf (QSE_T("%s: [% 16d] [% 16d] [% 16d]\n"), xtn->name, i, i, i);
 | 
							qse_printf (QSE_T("%s: [% 16d] [% 16d] [% 16d]\n"), xtn->name, i, i, i);
 | 
				
			||||||
		qse_spl_unlock (xtn->spl);
 | 
							qse_spl_unlock (xtn->spl);
 | 
				
			||||||
		i++;
 | 
							i++;
 | 
				
			||||||
		/*sleep (1);*/
 | 
							/*qse_sleep (&sleep_interval);*/
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return i;
 | 
						return i;
 | 
				
			||||||
@ -153,7 +152,7 @@ int main ()
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		sprintf (locale, ".%u", (unsigned int)codepage);
 | 
							qse_mbsxfmt (locale, QSE_COUNTOF(locale), ".%u", (unsigned int)codepage);
 | 
				
			||||||
		setlocale (LC_ALL, locale);
 | 
							setlocale (LC_ALL, locale);
 | 
				
			||||||
		/*qse_setdflcmgrbyid (QSE_CMGR_SLMB);*/
 | 
							/*qse_setdflcmgrbyid (QSE_CMGR_SLMB);*/
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@ -164,7 +163,7 @@ int main ()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	set_signal (SIGINT, handle_sigint);
 | 
						set_signal (SIGINT, handle_sigint);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	qse_open_stdsios ();
 | 
						qse_open_stdsios_with_flags (QSE_SIO_LINEBREAK); /* to disable mutex protection on stdout & stderr */
 | 
				
			||||||
	test1();
 | 
						test1();
 | 
				
			||||||
	qse_close_stdsios ();
 | 
						qse_close_stdsios ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -2,18 +2,20 @@
 | 
				
			|||||||
#include <qse/si/Thread.hpp>
 | 
					#include <qse/si/Thread.hpp>
 | 
				
			||||||
#include <qse/si/mtx.h>
 | 
					#include <qse/si/mtx.h>
 | 
				
			||||||
#include <qse/si/sio.h>
 | 
					#include <qse/si/sio.h>
 | 
				
			||||||
 | 
					#include <qse/si/os.h>
 | 
				
			||||||
#include <qse/cmn/mem.h>
 | 
					#include <qse/cmn/mem.h>
 | 
				
			||||||
 | 
					#include <qse/cmn/str.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <locale.h>
 | 
					#include <locale.h>
 | 
				
			||||||
#if defined(_WIN32)
 | 
					#if defined(_WIN32)
 | 
				
			||||||
#	include <windows.h>
 | 
					#	include <windows.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <unistd.h>
 | 
					 | 
				
			||||||
#include <signal.h>
 | 
					#include <signal.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int g_stopreq = 0;
 | 
					static int g_stopreq = 0;
 | 
				
			||||||
 | 
					static qse_ntime_t sleep_interval = { 1, 0 };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static QSE::SpinLock g_prmtx;
 | 
					static QSE::SpinLock g_prmtx;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -32,7 +34,7 @@ public:
 | 
				
			|||||||
			qse_printf (QSE_T("m %p -> %d\n"), this, i);
 | 
								qse_printf (QSE_T("m %p -> %d\n"), this, i);
 | 
				
			||||||
			g_prmtx.unlock ();
 | 
								g_prmtx.unlock ();
 | 
				
			||||||
			i++;
 | 
								i++;
 | 
				
			||||||
			sleep (1);
 | 
								qse_sleep (&sleep_interval);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return i;
 | 
							return i;
 | 
				
			||||||
@ -55,7 +57,7 @@ public:
 | 
				
			|||||||
			qse_printf (QSE_T("fc %p -> %d\n"), this, i);
 | 
								qse_printf (QSE_T("fc %p -> %d\n"), this, i);
 | 
				
			||||||
			g_prmtx.unlock ();
 | 
								g_prmtx.unlock ();
 | 
				
			||||||
			i++;
 | 
								i++;
 | 
				
			||||||
			sleep (1);
 | 
								qse_sleep (&sleep_interval);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return i;
 | 
							return i;
 | 
				
			||||||
@ -73,7 +75,7 @@ static int func_ptr (QSE::Thread* thr)
 | 
				
			|||||||
		qse_printf (QSE_T("fp %p -> %d\n"), thr, i);
 | 
							qse_printf (QSE_T("fp %p -> %d\n"), thr, i);
 | 
				
			||||||
		g_prmtx.unlock ();
 | 
							g_prmtx.unlock ();
 | 
				
			||||||
		i++;
 | 
							i++;
 | 
				
			||||||
		sleep (1);
 | 
							qse_sleep (&sleep_interval);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return i;
 | 
						return i;
 | 
				
			||||||
@ -95,7 +97,7 @@ static int test1 (void)
 | 
				
			|||||||
			qse_printf (QSE_T("l %p -> %d\n"), thr, i);
 | 
								qse_printf (QSE_T("l %p -> %d\n"), thr, i);
 | 
				
			||||||
			g_prmtx.unlock ();
 | 
								g_prmtx.unlock ();
 | 
				
			||||||
			i++;
 | 
								i++;
 | 
				
			||||||
			sleep (1);
 | 
								qse_sleep (&sleep_interval);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return i;
 | 
							return i;
 | 
				
			||||||
@ -111,7 +113,7 @@ static int test1 (void)
 | 
				
			|||||||
			qse_printf (QSE_T("lc %p -> %d\n"), thr, i);
 | 
								qse_printf (QSE_T("lc %p -> %d\n"), thr, i);
 | 
				
			||||||
			g_prmtx.unlock ();
 | 
								g_prmtx.unlock ();
 | 
				
			||||||
			i++;
 | 
								i++;
 | 
				
			||||||
			sleep (1);
 | 
								qse_sleep (&sleep_interval);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return i;
 | 
							return i;
 | 
				
			||||||
@ -172,7 +174,7 @@ static int test1 (void)
 | 
				
			|||||||
				qse_printf (QSE_T("tl %p -> %d\n"), thr, i);
 | 
									qse_printf (QSE_T("tl %p -> %d\n"), thr, i);
 | 
				
			||||||
				g_prmtx.unlock ();
 | 
									g_prmtx.unlock ();
 | 
				
			||||||
				i++;
 | 
									i++;
 | 
				
			||||||
				sleep (1);
 | 
									qse_sleep (&sleep_interval);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			return i;
 | 
								return i;
 | 
				
			||||||
@ -204,7 +206,7 @@ static int test1 (void)
 | 
				
			|||||||
		    thr5.getState() == QSE::Thread::TERMINATED &&
 | 
							    thr5.getState() == QSE::Thread::TERMINATED &&
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		    thr6.getState() == QSE::Thread::TERMINATED) break;
 | 
							    thr6.getState() == QSE::Thread::TERMINATED) break;
 | 
				
			||||||
		sleep (1);
 | 
							qse_sleep (&sleep_interval);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (g_stopreq) 
 | 
						if (g_stopreq) 
 | 
				
			||||||
@ -277,7 +279,7 @@ int main ()
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		sprintf (locale, ".%u", (unsigned int)codepage);
 | 
							qse_mbsxfmt (locale, QSE_COUNTOF(locale), ".%u", (unsigned int)codepage);
 | 
				
			||||||
		setlocale (LC_ALL, locale);
 | 
							setlocale (LC_ALL, locale);
 | 
				
			||||||
		/*qse_setdflcmgrbyid (QSE_CMGR_SLMB);*/
 | 
							/*qse_setdflcmgrbyid (QSE_CMGR_SLMB);*/
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@ -288,7 +290,7 @@ int main ()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	set_signal (SIGINT, handle_sigint);
 | 
						set_signal (SIGINT, handle_sigint);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	qse_open_stdsios ();
 | 
						qse_open_stdsios_with_flags (QSE_SIO_LINEBREAK);
 | 
				
			||||||
	test1();
 | 
						test1();
 | 
				
			||||||
	qse_close_stdsios ();
 | 
						qse_close_stdsios ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -1,18 +1,19 @@
 | 
				
			|||||||
#include <qse/si/thr.h>
 | 
					#include <qse/si/thr.h>
 | 
				
			||||||
#include <qse/si/sio.h>
 | 
					#include <qse/si/sio.h>
 | 
				
			||||||
 | 
					#include <qse/si/os.h>
 | 
				
			||||||
#include <qse/cmn/mem.h>
 | 
					#include <qse/cmn/mem.h>
 | 
				
			||||||
 | 
					#include <qse/cmn/str.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <locale.h>
 | 
					 | 
				
			||||||
#if defined(_WIN32)
 | 
					#if defined(_WIN32)
 | 
				
			||||||
#	include <windows.h>
 | 
					#	include <windows.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <locale.h>
 | 
				
			||||||
#include <signal.h>
 | 
					#include <signal.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int g_stopreq = 0;
 | 
					static int g_stopreq = 0;
 | 
				
			||||||
 | 
					static qse_ntime_t sleep_interval = { 1, 0 };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct thr_xtn_t
 | 
					struct thr_xtn_t
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -20,16 +21,19 @@ struct thr_xtn_t
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
typedef struct thr_xtn_t thr_xtn_t;
 | 
					typedef struct thr_xtn_t thr_xtn_t;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int thr_func (qse_thr_t* thr, void* ctx)
 | 
					static int thr_func (qse_thr_t* thr, void* ctx)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int i = 0;
 | 
						int i = 0;
 | 
				
			||||||
	thr_xtn_t* xtn = qse_thr_getxtn(thr);
 | 
						thr_xtn_t* xtn = qse_thr_getxtn(thr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	while (!xtn->stopreq)
 | 
						while (!xtn->stopreq)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		qse_printf (QSE_T("%d\n"), i);
 | 
							qse_printf (QSE_T("%d\n"), i);
 | 
				
			||||||
		i++;
 | 
							i++;
 | 
				
			||||||
		sleep (1);
 | 
							qse_sleep (&sleep_interval);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return i;
 | 
						return i;
 | 
				
			||||||
@ -58,7 +62,7 @@ static int test1 (void)
 | 
				
			|||||||
	while (!g_stopreq)
 | 
						while (!g_stopreq)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		if (qse_thr_getstate(thr) == QSE_THR_TERMINATED) break;
 | 
							if (qse_thr_getstate(thr) == QSE_THR_TERMINATED) break;
 | 
				
			||||||
		sleep (1);
 | 
							qse_sleep (&sleep_interval);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (g_stopreq) 
 | 
						if (g_stopreq) 
 | 
				
			||||||
@ -118,7 +122,7 @@ int main ()
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		sprintf (locale, ".%u", (unsigned int)codepage);
 | 
							qse_mbsxfmt (locale, QSE_COUNTOF(locale), ".%u", (unsigned int)codepage);
 | 
				
			||||||
		setlocale (LC_ALL, locale);
 | 
							setlocale (LC_ALL, locale);
 | 
				
			||||||
		/*qse_setdflcmgrbyid (QSE_CMGR_SLMB);*/
 | 
							/*qse_setdflcmgrbyid (QSE_CMGR_SLMB);*/
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,9 @@
 | 
				
			|||||||
#include <qse/si/Thread.hpp>
 | 
					#include <qse/si/Thread.hpp>
 | 
				
			||||||
#include <qse/si/mtx.h>
 | 
					#include <qse/si/mtx.h>
 | 
				
			||||||
#include <qse/si/sio.h>
 | 
					#include <qse/si/sio.h>
 | 
				
			||||||
 | 
					#include <qse/si/os.h>
 | 
				
			||||||
#include <qse/cmn/mem.h>
 | 
					#include <qse/cmn/mem.h>
 | 
				
			||||||
 | 
					#include <qse/cmn/str.h>
 | 
				
			||||||
#include <qse/cmn/HeapMmgr.hpp>
 | 
					#include <qse/cmn/HeapMmgr.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <locale.h>
 | 
					#include <locale.h>
 | 
				
			||||||
@ -9,11 +11,12 @@
 | 
				
			|||||||
#	include <windows.h>
 | 
					#	include <windows.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <unistd.h>
 | 
					 | 
				
			||||||
#include <signal.h>
 | 
					#include <signal.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int g_stopreq = 0;
 | 
					static int g_stopreq = 0;
 | 
				
			||||||
 | 
					static qse_ntime_t sleep_interval = { 1, 0 };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QSE::HeapMmgr g_heap_mmgr (QSE::Mmgr::getDFL(), 30000);
 | 
					QSE::HeapMmgr g_heap_mmgr (QSE::Mmgr::getDFL(), 30000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -30,7 +33,7 @@ public:
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			qse_printf (QSE_T("m %p -> %d\n"), this, i);
 | 
								qse_printf (QSE_T("m %p -> %d\n"), this, i);
 | 
				
			||||||
			i++;
 | 
								i++;
 | 
				
			||||||
			sleep (1);
 | 
								qse_sleep (&sleep_interval);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return i;
 | 
							return i;
 | 
				
			||||||
@ -51,7 +54,7 @@ public:
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			qse_printf (QSE_T("fc %p -> %d\n"), this, i);
 | 
								qse_printf (QSE_T("fc %p -> %d\n"), this, i);
 | 
				
			||||||
			i++;
 | 
								i++;
 | 
				
			||||||
			sleep (1);
 | 
								qse_sleep (&sleep_interval);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return i;
 | 
							return i;
 | 
				
			||||||
@ -67,7 +70,7 @@ static int func_ptr (QSE::Thread* thr)
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
		qse_printf (QSE_T("fp %p -> %d\n"), thr, i);
 | 
							qse_printf (QSE_T("fp %p -> %d\n"), thr, i);
 | 
				
			||||||
		i++;
 | 
							i++;
 | 
				
			||||||
		sleep (1);
 | 
							qse_sleep (&sleep_interval);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return i;
 | 
						return i;
 | 
				
			||||||
@ -87,7 +90,7 @@ static int test1 (void)
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			qse_printf (QSE_T("l %p -> %d\n"), thr, i);
 | 
								qse_printf (QSE_T("l %p -> %d\n"), thr, i);
 | 
				
			||||||
			i++;
 | 
								i++;
 | 
				
			||||||
			sleep (1);
 | 
								qse_sleep (&sleep_interval);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return i;
 | 
							return i;
 | 
				
			||||||
@ -101,7 +104,7 @@ static int test1 (void)
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			qse_printf (QSE_T("lc %p -> %d\n"), thr, i);
 | 
								qse_printf (QSE_T("lc %p -> %d\n"), thr, i);
 | 
				
			||||||
			i++;
 | 
								i++;
 | 
				
			||||||
			sleep (1);
 | 
								qse_sleep (&sleep_interval);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return i;
 | 
							return i;
 | 
				
			||||||
@ -160,7 +163,7 @@ static int test1 (void)
 | 
				
			|||||||
			{
 | 
								{
 | 
				
			||||||
				qse_printf (QSE_T("tl %p -> %d\n"), thr, i);
 | 
									qse_printf (QSE_T("tl %p -> %d\n"), thr, i);
 | 
				
			||||||
				i++;
 | 
									i++;
 | 
				
			||||||
				sleep (1);
 | 
									qse_sleep (&sleep_interval);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			return i;
 | 
								return i;
 | 
				
			||||||
@ -192,7 +195,7 @@ static int test1 (void)
 | 
				
			|||||||
		    thr5.getState() == QSE::Thread::TERMINATED &&
 | 
							    thr5.getState() == QSE::Thread::TERMINATED &&
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		    thr6.getState() == QSE::Thread::TERMINATED) break;
 | 
							    thr6.getState() == QSE::Thread::TERMINATED) break;
 | 
				
			||||||
		sleep (1);
 | 
							qse_sleep (&sleep_interval);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (g_stopreq) 
 | 
						if (g_stopreq) 
 | 
				
			||||||
@ -265,7 +268,7 @@ int main ()
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		sprintf (locale, ".%u", (unsigned int)codepage);
 | 
							qse_mbsxfmt (locale, QSE_COUNTOF(locale), ".%u", (unsigned int)codepage);
 | 
				
			||||||
		setlocale (LC_ALL, locale);
 | 
							setlocale (LC_ALL, locale);
 | 
				
			||||||
		/*qse_setdflcmgrbyid (QSE_CMGR_SLMB);*/
 | 
							/*qse_setdflcmgrbyid (QSE_CMGR_SLMB);*/
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,9 @@
 | 
				
			|||||||
#include <qse/si/Condition.hpp>
 | 
					#include <qse/si/Condition.hpp>
 | 
				
			||||||
#include <qse/si/mtx.h>
 | 
					#include <qse/si/mtx.h>
 | 
				
			||||||
#include <qse/si/sio.h>
 | 
					#include <qse/si/sio.h>
 | 
				
			||||||
 | 
					#include <qse/si/os.h>
 | 
				
			||||||
#include <qse/cmn/mem.h>
 | 
					#include <qse/cmn/mem.h>
 | 
				
			||||||
 | 
					#include <qse/cmn/str.h>
 | 
				
			||||||
#include <qse/cmn/HeapMmgr.hpp>
 | 
					#include <qse/cmn/HeapMmgr.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -11,11 +13,11 @@
 | 
				
			|||||||
#	include <windows.h>
 | 
					#	include <windows.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <unistd.h>
 | 
					 | 
				
			||||||
#include <signal.h>
 | 
					#include <signal.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int g_stopreq = 0;
 | 
					static int g_stopreq = 0;
 | 
				
			||||||
 | 
					static qse_ntime_t sleep_interval = { 1, 0 };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
QSE::HeapMmgr g_heap_mmgr (QSE::Mmgr::getDFL(), 30000);
 | 
					QSE::HeapMmgr g_heap_mmgr (QSE::Mmgr::getDFL(), 30000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -101,7 +103,7 @@ static int test1 (void)
 | 
				
			|||||||
		qse_printf (QSE_T("signalling ....(nterm = %d)\n"), nterm);
 | 
							qse_printf (QSE_T("signalling ....(nterm = %d)\n"), nterm);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		rqdata.cnd.signal ();
 | 
							rqdata.cnd.signal ();
 | 
				
			||||||
		sleep (1);
 | 
							qse_sleep (&sleep_interval);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -161,7 +163,7 @@ int main ()
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		sprintf (locale, ".%u", (unsigned int)codepage);
 | 
							qse_mbsxfmt (locale, QSE_COUNTOF(locale), ".%u", (unsigned int)codepage);
 | 
				
			||||||
		setlocale (LC_ALL, locale);
 | 
							setlocale (LC_ALL, locale);
 | 
				
			||||||
		/*qse_setdflcmgrbyid (QSE_CMGR_SLMB);*/
 | 
							/*qse_setdflcmgrbyid (QSE_CMGR_SLMB);*/
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user