Ejemplo n.º 1
0
void WinFrame::OnClose(wxCloseEvent& event)
{
#ifdef AC_MULTI_THREADED

    if (thread_)
    {
        if (computing_)
        {
            auto answer = wxMessageBox(
                              "A computation process has not been completed!\n\nDo you want to terminate this process?",
                              "Computation Pending",
                              wxYES | wxNO | wxNO_DEFAULT
                          );

            if (answer == wxYES)
            {
                /* Terminate abnormal */
                exit(0);
            }
            else
                return;
        }
        else
            JoinThread();
    }

#endif

    /* Save configuration */
    SaveConfig(configFilename);

    /* Close frame */
    wxFrame::OnCloseWindow(event);
}
Ejemplo n.º 2
0
void CScriptThread::Join()
{
	CAppServer::Inst()->Log("Stop ScriptThread");

	PutSemaphore(&m_smThread);
	JoinThread(&m_hThread);

	CAppServer::Inst()->Log("ScriptThread stopped");
}
Ejemplo n.º 3
0
bool WinFrame::ExecExpr(const std::string& expr)
{
    /* If expression is empty -> show information */
    if (expr.empty())
        ShowIntro();
    else if (expr == "exit")
    {
        /* Clear input to avoid storing "exit" in the config-file */
        SetInput("");
        Close();
    }
    else if (expr == "demo")
        ShowDemo();
    else if (expr == "const")
        ShowConstants();
    else if (expr == "clear")
    {
        constantsSet_.constants.clear();
        constantsSet_.ResetStd();
        ShowConstants();
    }
    else
    {
        /* Setup compute mode */
        Ac::ComputeMode mode;
        mode.degree = GetOptionDegree();

        /* Show status message */
        SetOutput("computing ...");

#ifdef AC_MULTI_THREADED

        /* Wait until previous thread has successfully terminated */
        if (computing_)
            return false;
        JoinThread();

#endif

        /* Compute expression */
#ifdef AC_MULTI_THREADED

        computing_ = true;
        thread_ = std::unique_ptr<std::thread>(new std::thread(&WinFrame::ComputeThreadProc, this, expr, mode));

#else

        ComputeThreadProc(expr.ToStdString(), mode);

#endif
    }

    return true;
}
Ejemplo n.º 4
0
// Destructor
_Server::~_Server() {
	Done = true;
	JoinThread();

	Save->SaveClock(Clock);

	delete MapManager;
	delete BattleManager;
	delete ObjectManager;
	delete Scripting;
	delete Save;
	delete Thread;
}
Ejemplo n.º 5
0
    void Thread::Join()
    {
        if (!_handle)
            return;

        if (_state == ThreadStateRunning)
        {
            _task->_stopRequested = true;
            _state = ThreadStateStopRequested;
        }
        
        JoinThread(_handle);
        _handle = 0;
        _task = 0;
    }
Ejemplo n.º 6
0
Frontend::~Frontend( )
{
  if( fe )
    fe->abort = 1;

  up = false;
  JoinThread( );

  Close( );

  LockPorts( );
  for( std::map<int, Port *>::iterator it = ports.begin( ); it != ports.end( ); it++ )
    delete it->second;
  UnlockPorts( );
}
Ejemplo n.º 7
0
void AudioPluginOSX::StopAudio()
{
	if (mAudioThread == kInvalidThreadHandle)
		return;

	// Tell the thread to stop running.
	mKeepRunning = false;

	if (mAudioThread != kInvalidThreadHandle)
	{
		JoinThread(mAudioThread, -1);
		mAudioThread = kInvalidThreadHandle;
	}

	// Remove the sync function.
	FramerateLimiter_SetAuxillarySyncFunction(NULL, NULL);
}
Ejemplo n.º 8
0
int gxThread::JoinThread(thrPool *thread_pool)
// Make the process wait until all the threads in the 
// specified pool have finished executing. Returns a
// non-zero value if the threads cannot be joined.
{
  if(!thread_pool) return 1;
  
  thrPoolNode *ptr = thread_pool->GetHead();

  while(ptr) {
    int rv = JoinThread(ptr->GetThreadPtr());
    if(rv) return rv;
    ptr = ptr->GetNext();
  }

  return 0;
}
Ejemplo n.º 9
0
void Frontend::Shutdown( )
{
  up = false;
  JoinThread( );
  Close( );
}
Ejemplo n.º 10
0
void CThread::StopThread()
{
  AsyncStopThread();
  JoinThread();
}
Ejemplo n.º 11
0
	void Strategy::StartPerformThread(const ArtifactSet &artifacts, ProgressListener &progress)
	{
		JoinThread();
		_threadFunc = new PerformFunc(this, new ArtifactSet(artifacts), &progress);
		_thread = new boost::thread(*_threadFunc);
	}