From: Guilhem Lavaux Date: Sun, 1 Aug 1999 07:26:36 +0000 (+0000) Subject: wxMemoryStream doc updated X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/f439844be27aa4ec09dd1d3365ce44653291c2af wxMemoryStream doc updated Added auto-destruction in wxThread::Delete and wxThread::Kill Fixed thread destruction in thread sample git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3229 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/latex/wx/strmmem.tex b/docs/latex/wx/strmmem.tex index f22a4bdaa0..523b4977fb 100644 --- a/docs/latex/wx/strmmem.tex +++ b/docs/latex/wx/strmmem.tex @@ -15,17 +15,6 @@ \helpref{wxStreamBuffer}{wxstreamBuffer} -\wxheading{Remark} - -You can create a similar stream by this way: - -\begin{verbatim} - wxStreamBuffer *sb = new wxStreamBuffer(wxStreamBuffer::read); - wxInputStream *input = new wxInputStream(sb); - - sb->SetBufferIO(data, data\_end); -\end{verbatim} - % ---------- % Members % ---------- @@ -61,33 +50,6 @@ Destructor. \helpref{wxStreamBuffer}{wxstreamBuffer} -\wxheading{Remark} - -You can create a similar stream by this way: - -\begin{verbatim} - wxStreamBuffer *sb = new wxStreamBuffer(wxStreamBuffer::write); - wxOutputStream *input = new wxOutputStream(sb); - - // If there are data - sb->SetBufferIO(data, data\_end); - // Else - sb->Fixed(FALSE); -\end{verbatim} - -This way is also useful to create read/write memory stream: - -\begin{verbatim} - wxStreamBuffer *sb = new wxStreamBuffer(wxStreamBuffer::read\_write); - wxOutputStream *output = new wxOutputStream(sb); - wxInputStream *input = new wxInputStream(sb); - - // If there are data - sb->SetBufferIO(data, data\_end); - // Else - sb->Fixed(FALSE); -\end{verbatim} - % ---------- % Members % ---------- @@ -111,3 +73,15 @@ stream. Destructor. +\membersection{wxMemoryOutputStream::CopyTo} + +\constfunc{size\_t}{CopyTo}{\param{char *}{buffer}, \param{size\_t }{len}} + +CopyTo allowed you to transfer data from the internal buffer of +wxMemoryOutputStream to an external buffer. \it{len} specifies the size of +the buffer. + +\wxheading{Returned value} + +CopyTo returns the number of bytes copied to the buffer. Generally it is either +len or the size of the stream buffer. diff --git a/include/wx/gsocket.h b/include/wx/gsocket.h index 59739c14c5..212a7063ce 100644 --- a/include/wx/gsocket.h +++ b/include/wx/gsocket.h @@ -46,7 +46,8 @@ typedef enum { GSOCK_INVADDR, GSOCK_INVSOCK, GSOCK_NOHOST, - GSOCK_INVPORT + GSOCK_INVPORT, + GSOCK_TRYAGAIN } GSocketError; typedef enum { diff --git a/samples/thread/test.cpp b/samples/thread/test.cpp index b350260d8e..706ac23584 100644 --- a/samples/thread/test.cpp +++ b/samples/thread/test.cpp @@ -404,7 +404,9 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) ) size_t count = m_threads.Count(); for ( size_t i = 0; i < count; i++ ) { - m_threads[i]->Delete(); + // We must always use 0 because Delete() calls OnThreadExit() and + // OnThreadExit() removed 0 from the array. + m_threads[0]->Delete(); } Close(TRUE); diff --git a/src/common/event.cpp b/src/common/event.cpp index 831b257dcd..d0e063d025 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -562,6 +562,7 @@ bool wxEvtHandler::ProcessThreadEvent(wxEvent& event) wxPendingEvents->Append(this); wxPendingEventsLocker->Leave(); + // TODO: Wake up idle handler for the other platforms. #ifdef __WXGTK__ if (g_isIdle) wxapp_install_idle_handler(); diff --git a/src/unix/threadpsx.cpp b/src/unix/threadpsx.cpp index a6f79d8db1..75b3bff757 100644 --- a/src/unix/threadpsx.cpp +++ b/src/unix/threadpsx.cpp @@ -100,8 +100,12 @@ public: wxMutex::wxMutex() { + pthread_mutexattr_t attr_type; + + pthread_mutexattr_settype( &attr_type, PTHREAD_MUTEX_FAST_NP ); + p_internal = new wxMutexInternal; - pthread_mutex_init( &(p_internal->p_mutex), (const pthread_mutexattr_t*) NULL ); + pthread_mutex_init( &(p_internal->p_mutex), (const pthread_mutexattr_t*) &attr_type ); m_locked = 0; } @@ -696,6 +700,8 @@ wxThread::ExitCode wxThread::Delete() // wait until the thread stops p_internal->Wait(); } + //GL: As we must auto-destroy, the destruction must happen here. + delete this; return NULL; } @@ -717,6 +723,8 @@ wxThreadError wxThread::Kill() return wxTHREAD_MISC_ERROR; } + //GL: As we must auto-destroy, the destruction must happen here (2). + delete this; return wxTHREAD_NO_ERROR; }