Exemple #1
0
void SingleThreadedApplication::notify(const Wt::WEvent& event)
{
  if (appThread_.get_id() == boost::thread::id()) { // not-a-thread
    done_ = false;
    log("debug") << "STA" << ": starting thread";
    appThread_ = boost::thread(boost::bind(&SingleThreadedApplication::run,
					   this));
    waitDone();
  }

  if (boost::this_thread::get_id() == appThread_.get_id()) {
    /* This could be from within a recursive event loop */
    log("debug") << "STA" << ": notify() called within app thread";
    threadNotify(event);
    return;
  }

  if (event.eventType() == Wt::ResourceEvent) {
    /*
     * We do not relay resource events since these will not unlock
     * a recursive event loop and thus we cannot communicate with the
     * private thread when it's blocked in a recursive event loop
     */
    log("debug") << "STA" << ": notify() for resource, handling in thread pool.";
    threadNotify(event);
    return;
  }

  event_ = &event;

  done_ = false;
  {
    log("debug") << "STA" << ": notifying thread";
    boost::mutex::scoped_lock lock(newEventMutex_);
    newEvent_ = true;
    newEventCondition_.notify_one();
  }

  waitDone();

  if (exception_) {
    exception_ = false;
    throw std::runtime_error("STA: rethrowing exception");
  }

  if (finalized_) {
    log("debug") << "STA" << ": joining thread";
    appThread_.join();
    appThread_ = boost::thread();
  }
}
Exemple #2
0
bool
TestBindata::cbRetrieve (QByteArray serverdata)
{
	TVERIFY (m_testdata == serverdata,
	         "Our local file is different from the retrieved one");

	waitDone ();
	return true;
}
Exemple #3
0
bool
TestColl::cbList (const QVariantList &lst)
{
	for (int i = 0; i < lst.size (); i++)
	{
		qDebug () << lst.at (i).toString ();
	}
	waitDone ();
	return true;
}
Exemple #4
0
bool
TestBindata::cbRemove2 (QVariantList list)
{
	QVariant hash (m_serverhash);

	TVERIFY (!list.contains (hash), "Server still contains Bindata");

	waitDone ();
	return true;
}
Exemple #5
0
bool
TestBindata::cbRemove ()
{
#if XMMS_IPC_VERSION >=11
	m_client.bindata.list ()(this, SLOT (cbRemove2 (QVariantList)));
#else
	waitDone ();
#endif
	return true;
}
Exemple #6
0
bool
TestBindata::cbList (QVariantList list)
{
	QVariant hash (m_serverhash);

	TVERIFY (list.contains (hash), "Server doesn't have the file we sent");

	waitDone ();
	return true;
}
Exemple #7
0
//Send a block of data to the FPGA, raise the execution signal, wait for the execution
// signal to be lowered, then read back up to values of results
// startAddress: local address on FPGA input buffer to begin writing at
// length: # of bytes to write
// inData: data to be sent to FPGA
// maxWaitTime: # of seconds to wait until execution timeout
// outData: readback data buffer (if function returns successfully)
// maxOutLength: maximum length of outData buffer provided
// outputLength: number of bytes actually returned (if function returns successfully)
// Returns true if entire process is successful.
// If function fails for any reason, returns false.
//  Check error code with getLastError().
//  error == FAILCAPACITY: The output was larger than provided buffer.  Rather than the number of
//			bytes actually returned, the outputLength variable will contain the TOTAL number bytes the
//			function wanted to return (the number of bytes actually returned will be maxOutLength).
//			If this occurs, user should read back bytes {maxOutLength, outputLength - 1} manually
//			with a subsequent sendRead command.
//  error == FAILREADACK: The write and execution phases completed correctly, but we retried
//			the readback phase too many times.  In this case, like the FAILCAPICITY error, outputLength
//			will contain the TOTAL number bytes the	function wanted to return.  The state of outData is unknown,
//			but some data has been partially written.  The user could try calling sendRead
//			from {0, outputLength-1} manually if re-calling sendWriteAndRun is not easy
//			(for example, if inData and outData overlapped).
//  error == anything else: see normal error list
BOOL PICO_SIRC::sendWriteAndRun(uint32_t startAddress, uint32_t inLength, uint8_t *inData, 
							  uint32_t maxWaitTimeInMsec, uint8_t *outData, uint32_t maxOutLength, 
							  uint32_t *outputLength)
{
	setLastError( 0);

	//Check the input parameters
	if(!inData){
		setLastError( INVALIDBUFFER);
		return false;
	}
	if(startAddress > OUTPUT_OFFSET){
		setLastError( INVALIDADDRESS);
		return false;
	}
	if(inLength == 0 || startAddress + inLength > OUTPUT_OFFSET){
		setLastError( INVALIDLENGTH);
		return false;
	}

	//Check the output parameters
	if(!outData){
		setLastError( INVALIDBUFFER);
		return false;
	}
	if(maxOutLength == 0 || maxOutLength > OUTPUT_OFFSET){
		setLastError( INVALIDLENGTH);
		return false;
	}

	//Send the data to the FPGA
    if (!sendWrite(startAddress,inLength,inData)){
        return false;
    }

    //Send the run cmd
    if (!sendRun()){
        return false;
    }

    //Wait till done
    if (!waitDone( maxWaitTimeInMsec)){
        return false;
    }

    //Read back data
    //BUGBUG what about partial results??
    if (!sendRead(0,maxOutLength,outData)){
        return false;
    }
    *outputLength = maxOutLength;

    //and done
    return true;
}
Exemple #8
0
bool
TestBindata::cbAdd (QString hash)
{
	m_serverhash = hash;

	TVERIFY (hash.toAscii () ==
	    QCryptographicHash::hash (m_testdata, QCryptographicHash::Md5).toHex (),
		"Returned String doesn't match md5 hash of data");

	waitDone ();
	return true;
}
void DispatchThread::notify(const WEvent& event)
{
  event_ = &event;

  done_ = false;

  if (dispatchObject_)
    dispatchObject_->propagateEvent();
  else
    myPropagateEvent();

  waitDone();
}
void DispatchThread::notify(const WEvent& event)
{
  _event = &event;

  _done = false;

  if (_dispatchObject)
    _dispatchObject->propagateEvent();
  else
    myPropagateEvent();

  waitDone();
}
Exemple #11
0
CProcess::~CProcess()
{
	waitDone();
}
Exemple #12
0
CBackupDeleter::~CBackupDeleter()
{
	waitDone();
}
Exemple #13
0
CBackupStatusUpdater::~CBackupStatusUpdater()
{
	waitDone();
}