Update of /cvsroot/audacity/lib-src/lib-widget-extra
In directory
sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv25302/lib-src/lib-widget-extra
Added Files:
NonGuiThread.cpp NonGuiThread.h
Log Message:
-Added plug in capability for mod-script-pipe
--- NEW FILE: NonGuiThread.h ---
/*************************************************************************
NonGuiThread.h
James Crook
(C) Audacity Developers, 2007
wxWidgets license. See Licensing.txt
*************************************************************************/
#if
!defined(AFX_NONGUITHREAD_H__E8F7FC2B_CB13_497B_A556_18551596AFD9__INCLUDED_)
#define AFX_NONGUITHREAD_H__E8F7FC2B_CB13_497B_A556_18551596AFD9__INCLUDED_
typedef void (*tGenericFn)(void);
//#include "AllCommands.h" // for tGenericFn
//#include "WidgetExtra.h"
class /*WIDGET_EXTRA_DLL*/ NonGuiThread : public wxThread
{
public:
NonGuiThread(tGenericFn pFn);
virtual ~NonGuiThread();
NonGuiThread::ExitCode Entry();
static void RunInThread(tGenericFn pFn);
static NonGuiThread * StartChild( tGenericFn pFn );
public:
bool mbExit;
tGenericFn mpFn;
static bool IsLive;
};
#endif //
!defined(AFX_NONGUITHREAD_H__E8F7FC2B_CB13_497B_A556_18551596AFD9__INCLUDED_)
--- NEW FILE: NonGuiThread.cpp ---
/*************************************************************************
NonGuiThread.cpp
James Crook
(C) Audacity Developers, 2007
wxWidgets license. See Licensing.txt
**********************************************************************//**
\class NonGuiThread
\brief NonGuiThread a thread class that allows non-GUI activities to
take place in the background without killing the GUI.
*//**********************************************************************/
#include <wx/wx.h>
#include <wx/apptrait.h>
#include "NonGuiThread.h"
bool NonGuiThread::IsLive=false;
NonGuiThread::NonGuiThread(tGenericFn pFn)
{
mpFn = pFn;
IsLive=true;
mbExit = false;
}
NonGuiThread::~NonGuiThread()
{
IsLive=false;
}
NonGuiThread::ExitCode NonGuiThread::Entry()
{
// The while isn't needed here, but may be later if we break the function
// up...
while( !TestDestroy() && !mbExit )
{
mbExit=true;
(*mpFn)();
}
return (ExitCode)0;
}
// This one runs the function and only returns when function
// has run to completion.
void NonGuiThread::RunInThread(tGenericFn pFn)
{
wxAppTraits *traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
wxASSERT( traits );//"no wxAppTraits in RunInThread()?"
void *cookie = NULL;
// disable all app windows while waiting for the child process to finish
cookie = traits->BeforeChildWaitLoop();
NonGuiThread * mpThread = new NonGuiThread(pFn);
mpThread->Create();
mpThread->Resume();
wxLogDebug(wxT("Into the thread..."));
while( mpThread->IsLive )
{
wxMilliSleep( 100 );
//traits->AlwaysYield();
wxYield();
}
traits->AfterChildWaitLoop(cookie);
}
// This function starts the thread and returns immediately.
NonGuiThread * NonGuiThread::StartChild( tGenericFn pFn )
{
NonGuiThread * pThread = new NonGuiThread(pFn);
//pThread->mpFn = pFn;
pThread->Create();
pThread->Resume();
return pThread;
}
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs