Пример #1
0
JavaObject::~JavaObject()
{
	UPDATE_STATS(-1, isDetached() ? -1 : 0);

	if (javaObject_ || refTableKey_ > 0) {
		deleteGlobalRef();
	}
}
Пример #2
0
JavaObject::~JavaObject()
{
	UPDATE_STATS(-1, isDetached() ? -1 : 0);

	if (javaObject_) {
		deleteGlobalRef();
	}
}
Пример #3
0
int main(int argc, char **argv) {
	char commandBuf[BUFSIZE + 1];
	struct Process proc;
	char path[BUFSIZE + 1] = DEFAULT_PATH;
	char *command;
	int detached;

	/* Set attribute to gray on black. */
	Print("\x1B[37m");

	while (true) {
		/* Print shell prompt (bright cyan on black background) */
		Print("\x1B[1;36m$\x1B[37m ");

		/* Read a line of input */
		Read_Line(commandBuf, sizeof(commandBuf));
		command = Strip_Leading_Whitespace(commandBuf);
		Trim_Newline(command);
		detached = isDetached(command);

		/*
		 * Handle some special commands
		 */
		if (strcmp(command, "exit") == 0) {
			/* Exit the shell */
			break;
		} else if (strcmp(command, "pid") == 0) {
			/* Print the pid of this process */
			Print("%d\n", Get_PID());
			continue;
		} else if (strcmp(command, "exitCodes") == 0) {
			/* Print exit codes of spawned processes. */
			exitCodes = 1;
			continue;
		} else if (strncmp(command, "path=", 5) == 0) {
			/* Set the executable search path */
			strcpy(path, command + 5);
			continue;
		} else if (strcmp(command, "") == 0) {
			/* Blank line. */
			continue;
		}

		proc.command = Strip_Leading_Whitespace(command);
		if (!Copy_Token(proc.program, proc.command)) {
			Print("Error: invalid command\n");
			continue;
		}

		Spawn_Single_Command(&proc, path, detached);
		if (detached && proc.pid > 0)
			Print("[%d]\n", proc.pid);

	}

	Print_String("DONE!\n");
	return 0;
}
Пример #4
0
  void AmSession::stop()
#endif  
{
  DBG("AmSession::stop()\n");

  if (!isDetached())
    AmMediaProcessor::instance()->clearSession(this);
  else
    clearAudio();
}
Пример #5
0
AXObject* AXSVGRoot::computeParent() const
{
    ASSERT(!isDetached());
    // If a parent was set because this is a remote SVG resource, use that
    // but otherwise, we should rely on the standard layout tree for the parent.
    if (m_parent)
        return m_parent;

    return AXLayoutObject::computeParent();
}
Пример #6
0
int
Thread::cancel()
{
    if (isNotOk() || !isStarted() || isDetached()) return(-1);
    if (isCanceled()) return(0);
    int status = ::pthread_cancel(state_.id_);
    ThreadMutexLock lock(state_.cs_);
    state_.canceled_ = true;
    setOk(status == 0);
    return(status);
}
Пример #7
0
int
Thread::join(void *&retval)
{
    if (isNotOk() || !isStarted() || isDetached()) return(-1);
    if (isJoined()) return(0);
    retval = NULL;
    int status = ::pthread_join(state_.id_, &retval);
    ThreadMutexLock lock(state_.cs_);
    state_.joined_ = true;
    setOk(status == 0);
    return(status);
}
Пример #8
0
void JavaObject::detach()
{
	handle_.MakeWeak(this, DetachCallback);

	if (isDetached()) {
		return;
	}

	UPDATE_STATS(0, 1);

	weakGlobalRef();
}
Пример #9
0
void JavaObject::detach()
{
	// WAIT A SECOND V8!!! DON'T KILL MY OBJECT YET! THE JVM MAY STILL WANT IT!
	persistent().ClearWeak(); // Make JS Strong Again!

	// if the JVM side is a weak reference or we have no object wrapped, don't do anything else
	if (isDetached()) {
		return;
	}

	// V8 says we don't need the object on the JS side
	// Let's make the object weak in the JVM now...
	MakeJavaWeak();
}
Пример #10
0
void JavaObject::detach()
{
	// WAIT A SECOND V8!!! DON'T KILL MY OBJECT YET! THE JVM MAY STILL WANT IT!
	persistent().ClearWeak();

	if (isDetached()) {
		return;
	}

	// V8 says we don't need the object on the JS side
	// Let's make the object weak in the JVM now...
	UPDATE_STATS(0, 1);
	weakGlobalRef();
}
Пример #11
0
void Thread::close()
{
	bool detached = isDetached();

#if !defined(CCXX_SIG_THREAD_ALARM) && !defined(__CYGWIN32__) && !defined(__MINGW32__) && !defined(WIN32)
	if(this == PosixThread::_timer)
		PosixThread::_arm.leaveMutex();
#endif
	setCancel(cancelDisabled);
//	if(_parent)
//		_parent->notify(this);
      
	// final can call destructor (that call Terminate)
	final();
Пример #12
0
void DecodedDataDocumentParser::appendBytes(const char* data, size_t length)
{
    if (!length)
        return;

    // This should be checking isStopped(), but XMLDocumentParser prematurely
    // stops parsing when handling an XSLT processing instruction and still
    // needs to receive decoded bytes.
    if (isDetached())
        return;

    String decoded = m_decoder->decode(data, length);
    updateDocument(decoded);
}
Пример #13
0
JavaObject::~JavaObject()
{
	UPDATE_STATS(-1, isDetached() ? -1 : 0);

	if (javaObject_ || refTableKey_ > 0) {
		deleteGlobalRef();
	}

	if (persistent().IsEmpty())
		return;
	assert(persistent().IsNearDeath());
	persistent().ClearWeak();
	persistent().Reset();
}
Пример #14
0
   Subscriber subscribe(const std::string &, uint32_t, void(T::*fun)(M), T *obj) {
      struct Thread : QThread {
         Thread(QObject*p):QThread(p){} ~Thread() override { quit(); wait(); } };
      static QPointer<Thread> thread = new Thread(qApp);
      thread->start(); // no-op if already started
      auto *timer = new QTimer;
      timer->start(1000/60);
      timer->moveToThread(thread);
      QObject::connect(timer, &QTimer::timeout, [timer, obj, fun]{
         auto const msec = QTime::currentTime().msecsSinceStartOfDay();
         auto val = timer->property("name");
         QVariant f;
         auto img = takeProperty<QImage>(timer, "image", 256, 256, QImage::Format_ARGB32_Premultiplied);
//         else img = {256, 256, QImage::Format_ARGB32_Premultiplied};
         Q_ASSERT(img.isDetached());
         qDebug() << val.isDetached() << timer->property("image").constData() << (void*)img.constBits();
//         QImage img{256, 256, QImage::Format_ARGB32_Premultiplied};
         img.fill(Qt::white);
         QPainter p{&img};
         constexpr int period = 3000;
         p.scale(img.width()/2.0, img.height()/2.0);
         p.translate(1.0, 1.0);
         p.rotate((msec % period) * 360.0/period);
         p.setPen({Qt::darkBlue, 0.1});
         p.drawLine(QLineF{{-1., 0.}, {1., 0.}});
         p.end();
         setProperty(timer, "image", img);
         img = std::move(img).convertToFormat(QImage::Format_RGB888).rgbSwapped();

         sensor_msgs::ImageConstPtr ptr{new sensor_msgs::Image{
               {img.constBits(), img.constBits() + img.sizeInBytes()},
               sensor_msgs::image_encodings::BGR8,
                     (uint32_t)img.height(), (uint32_t)img.width()}};
         (*obj.*fun)(ptr);
      });
      return {};
   }   
Пример #15
0
void DecodedDataDocumentParser::flush()
{
    // This should be checking isStopped(), but XMLDocumentParser prematurely
    // stops parsing when handling an XSLT processing instruction and still
    // needs to receive decoded bytes.
    if (isDetached())
        return;

    // null decoder indicates there is no data received.
    // We have nothing to do in that case.
    if (!m_decoder)
        return;

    String remainingData = m_decoder->flush();
    updateDocument(remainingData);
}
Пример #16
0
/*!
    Translates the elements in this array of QVector2D values
    by the components of \a value.

    \sa translated()
*/
void QVector2DArray::translate(const QVector2D& value)
{
    if (isDetached()) {
        // Modify the array in-place.
        int size = count();
        QVector2D *dst = data();
        for (int index = 0; index < size; ++index)
            *dst++ += value;
    } else {
        // Create a new array, translate the values, and assign.
        QArray<QVector2D> result;
        int size = count();
        const QVector2D *src = constData();
        QVector2D *dst = result.extend(size);
        for (int index = 0; index < size; ++index)
            *dst++ = *src++ + value;
        *this = result;
    }
}
Пример #17
0
Thread::~Thread()
{
    ThreadMutexLock lock(state_.cs_);

    if (isOk() && isStarted() && !isDetached())
    {
        void *retval = NULL;
        if (!isCanceled())
        {
            state_.canceled_ = true;
            ::pthread_cancel(state_.id_);
        }
        if (!isJoined())
        {
            state_.joined_ = true;
            ::pthread_join(state_.id_, &retval);
        }
    }
    ::pthread_attr_destroy(&state_.attr_);
    setOk(false);
}
Пример #18
0
/*!
    Transforms the elements in this array of QVector2D values
    by \a matrix.

    \sa transformed()
*/
void QVector2DArray::transform(const QMatrix4x4& matrix)
{
    if (isDetached()) {
        // Modify the array in-place.
        int size = count();
        QVector2D *dst = data();
        for (int index = 0; index < size; ++index) {
            *dst = (matrix * QVector3D(*dst, 0.0f)).toVector2D();
            ++dst;
        }
    } else {
        // Create a new array, transform the values, and assign.
        QArray<QVector2D> result;
        int size = count();
        const QVector2D *src = constData();
        QVector2D *dst = result.extend(size);
        for (int index = 0; index < size; ++index)
            *dst++ = (matrix * QVector3D(*src++, 0.0f)).toVector2D();
        *this = result;
    }
}
Пример #19
0
void XMLDocumentParser::doEnd()
{
#if ENABLE(XSLT)
    if (m_sawXSLTransform) {
        document()->setTransformSource(adoptPtr(new TransformSource(m_originalSourceForTransform.toString())));
        document()->setParsing(false); // Make the doc think it's done, so it will apply xsl sheets.
        document()->styleResolverChanged(RecalcStyleImmediately);

        // styleResolverChanged() call can detach the parser and null out its document.
        // In that case, we just bail out.
        if (isDetached())
            return;

        document()->setParsing(true);
        DocumentParser::stopParsing();
    }
#endif

    if (m_stream.error() == QXmlStreamReader::PrematureEndOfDocumentError
        || (m_wroteText && !m_sawFirstElement && !m_sawXSLTransform && !m_sawError))
        handleError(XMLErrors::fatal, qPrintable(m_stream.errorString()), textPosition());
}
Пример #20
0
// Returns a global reference to the wrapped Java object.
// If the object has become "detached" this will re-attach
// it to ensure the Java object will not get collected.
jobject JavaObject::getJavaObject()
{
	if (useGlobalRefs) {
		ASSERT(javaObject_ != NULL);

		// We must always return a valid Java proxy reference.
		// Otherwise we risk crashing in the calling code.
		// If we are "detached" we will re-attach whenever the Java
		// proxy is requested.
		if (isDetached()) {
			attach(NULL);
		}

		return javaObject_;
	} else {
		if (isWeakRef_) { // Did JS side try to collect our object already?
			// OH SNAP, DON'T KILL OUR OBJECT YET JVM!
			// make reference strong again on Java side if we can...
			jobject javaObject = ReferenceTable::clearWeakReference(refTableKey_);
			UPDATE_STATS(0, -1);
			if (javaObject == NULL) {
				// SHIT! Java collected it. ummmm, not much we can do here.
				// Maybe we can... Nope. It's gone. Live with it.
				LOGE(TAG, "Java object reference has been invalidated.");
			}

			isWeakRef_ = false; // not weak on Java side anymore

			// tell V8 to let us know when it thinks the JS object can be collected again
			persistent().SetWeak(this, DetachCallback);
			persistent().MarkIndependent();

			return javaObject;
		}
		return ReferenceTable::getReference(refTableKey_);
	}
}
Пример #21
0
AXScrollView::~AXScrollView()
{
    ASSERT(isDetached());
}
Пример #22
0
void Thread::terminate(void)
{
#ifdef WIN32
	HANDLE hThread;

	if(!priv)
		return;

	hThread = priv->_hThread;

	if (!priv->_tid || isThread())
	{
		if( priv->_cancellation)
			::CloseHandle(priv->_cancellation);
      		if(hThread)
            		::CloseHandle(hThread);
		delete priv;
		priv = NULL;
      		return;
	}

	bool terminated = false;
	if(!priv->_active && hThread != NULL)
	{
		// NOTE: add a test in testthread for multiple
		// suspended Terminate
		ResumeThread(hThread);
		TerminateThread(hThread, 0);
		terminated = true;
	}
	else if(hThread != NULL)
	{
		switch(_cancel)	{
		case cancelImmediate:
			TerminateThread(hThread, 0);
			terminated = true;
			break;
		default:
			SetEvent(priv->_cancellation);
		}
	}
	if(hThread != NULL)
	{
		WaitForSingleObject(hThread, INFINITE);
		CloseHandle(hThread);
		hThread = NULL;
	}

// what if parent already exited?

//	if(_parent)
//		_parent->notify(this);
	if(priv->_cancellation != NULL)
		CloseHandle(priv->_cancellation);
	priv->_cancellation = NULL;
	priv->_tid = 0;
	if(getThread() == this)
		_self.setKey(DUMMY_INVALID_THREAD);

	if (terminated)
		final();
#else
	if(!priv)
		return;

        cctid_t jtid = priv->_jtid, tid = priv->_tid;

	if(jtid && (pthread_self() != jtid))
	{
		pthread_join(jtid, NULL);
		priv->_jtid = 0;
	}
	else if((pthread_self() != tid) && tid)
	{
		// in suspend thread cannot be cancelled or signaled
		// ??? rigth
		// ccxx_resume(priv->_tid);
		

		// assure thread has ran before we try to cancel...
		if(_start)
			_start->post();

		pthread_cancel(tid);
		if(!isDetached())
		{
			pthread_join(tid,NULL);
			priv->_tid = 0;
		}
	}

        pthread_attr_destroy(&priv->_attr);
#endif
	delete priv;
	priv = NULL;
}
Пример #23
0
QT_BEGIN_NAMESPACE

/*!
    \class QVector2DArray
    \brief The QVector2DArray class is a convenience for wrapping a QArray of QVector2D values.
    \since 4.8
    \ingroup qt3d
    \ingroup qt3d::arrays

    QVector2DArray is used to build an array of 2D vector values
    based on floating-point x and y arguments:

    \code
    QVector2DArray array;
    array.append(1.0f, 2.0f);
    array.append(-1.0f, 2.0f);
    array.append(1.0f, -2.0f);
    \endcode

    This is more convenient and readable than the equivalent with
    QArray:

    \code
    QArray<QVector2D> array;
    array.append(QVector2D(1.0f, 2.0f));
    array.append(QVector2D(-1.0f, 2.0f));
    array.append(QVector2D(1.0f, -2.0f));
    \endcode

    QVector2DArray also has convenience functions for transforming
    the contents of the array with translate(), translated(),
    transform(), and transformed().

    \sa QArray, QVector3DArray, QVector4DArray
*/

/*!
    \fn QVector2DArray::QVector2DArray()

    Constructs an empty array of QVector2D values.
*/

/*!
    \fn QVector2DArray::QVector2DArray(int size, const QVector2D& value)

    Constructs an array of QVector2D values with an initial \a size.
    All elements in the array are initialized to \a value.
*/

/*!
    \fn QVector2DArray::QVector2DArray(const QArray<QVector2D>& other)

    Constructs a copy of \a other.
*/

/*!
    \fn void QVector2DArray::append(qreal x, qreal y)
    \overload

    Appends (\a x, \a y) to this array of QVector2D values.
*/

/*!
    \fn void QVector2DArray::append(const QPointF& point)
    \overload

    Appends \a point to this array of QVector2D values.
*/

/*!
    \fn void QVector2DArray::append(const QPoint& point);
    \overload

    Appends \a point to this array of QVector2D values.
*/

/*!
    Multiplies the elements in this array of QVector2D values by
    the \a scale.

    \sa scaled()
*/
void QVector2DArray::scale(qreal scale)
{
    if (isDetached()) {
        // Modify the array in-place.
        int size = count();
        QVector2D *dst = data();
        for (int index = 0; index < size; ++index)
            *dst++ *= scale;
    } else {
        // Create a new array, translate the values, and assign.
        QArray<QVector2D> result;
        int size = count();
        const QVector2D *src = constData();
        QVector2D *dst = result.extend(size);
        for (int index = 0; index < size; ++index)
            *dst++ = *src++ * scale;
        *this = result;
    }
}
AccessibilityScrollView::~AccessibilityScrollView()
{
    ASSERT(isDetached());
}