Example #1
0
	BoxClass::~BoxClass()
	{
		// if there are remaining pointers we have other problems.
		DEBUGLOG(routing,_T("this = %p"),(void*)this);
		if (open) Close();
#ifdef DEBUG
		// prevent from endless destroy loop
		intrusive_ptr_add_ref(this);
		intrusive_ptr_add_ref(this);
		BoxListType::iterator i = FindInBoxList(this);
		if (i != boxList.end()) {
			UNREACHABLEC;
			//		boxList.erase(i);
		}
#endif
		TRACEC;
		debug_destruct_class(this);
		if (box) free(box);
	}
	bool compare_exchange(T* expected, T* desired, T** old = NULL) {
		bool success = ptr.compare_exchange_strong(expected, desired);
		if(success && expected != desired) {
			intrusive_ptr_add_ref(desired);
			intrusive_ptr_release(expected);
		}
		if(old)
			*old = expected;
		return success;
	}
void LLURLRequest::force_killed(void)
{
	// Avoid destructing the responder, if any, because that might
	// execute code that might crash now that the viewer is exiting.
	if (mResponder)
	{
		intrusive_ptr_add_ref(mResponder.get());
	}
	// Call base class.
	AIStateMachine::force_killed();
}
Example #4
0
	Capture::Capture()
        : Generator()
        , m_CameraOutputPort(*this)
        , m_Camera()
        , m_VideoBufferQueueSync()
        , m_VideoBufferQueue(2)
        , m_VideoBufferCurrent()
        , m_FirstSampleTime(chrono::system_clock::time_point::max())
        , m_SampleTime(0.0f)
	{
        intrusive_ptr_add_ref(&m_CameraOutputPort);
	}
Example #5
0
       VideoDecoder::VideoDecoder(Registry const &r)
        : media::VideoDecoder()
        , m_Registry(r)
        , m_OMXHandle(0)
        , m_VideoInputPort(*this)
        , m_VideoOutputPort(*this)
        , m_Profile(kCodecProfileLowLatency)
        , m_VideoBitRate(400000)
        , m_VideoSampleSize(0,0)
        , m_VideoSampleRate(0.0f)
        , m_VideoSampleTime(0.0f)
    {
        intrusive_ptr_add_ref(&m_VideoInputPort);
        intrusive_ptr_add_ref(&m_VideoOutputPort);

        OMX_CALLBACKTYPE callbacks;
        callbacks.EventHandler = &VideoDecoder::_omxEventHandler;
        callbacks.EmptyBufferDone = &VideoDecoder::_omxEmptyBufferDone;
        callbacks.FillBufferDone = &VideoDecoder::_omxFillBufferDone;
        SI(OMXCore).createComponentHandle(m_OMXHandle, m_Registry.ocxIndex, this, &callbacks);
    }
void abstract_broker::launch(execution_unit* eu, bool is_lazy, bool is_hidden) {
  CAF_ASSERT(eu != nullptr);
  CAF_ASSERT(eu == &backend());
  // add implicit reference count held by middleman/multiplexer
  if (!is_hidden)
    register_at_system();
  CAF_PUSH_AID(id());
  CAF_LOG_TRACE("init and launch broker:" << CAF_ARG(id()));
  if (is_lazy && mailbox().try_block())
    return;
  intrusive_ptr_add_ref(ctrl());
  eu->exec_later(this);
}
Example #7
0
	Writer::Writer(Registry const &r)
		: media::Writer()
        , m_FFMpegOutputFormat(r.m_FFMpegOutputFormat)
        , m_ContainerFormat(r.m_ContainerFormat)
        , m_VideoInputPort(*this)
        , m_FFMpegFormatCtx(0)
        , m_FFMpegBuffer()
        , m_FFMpegIOContext(0)
        , m_FFMpegVideoStream(0)
        , m_TestFile()
    {
        intrusive_ptr_add_ref(&m_VideoInputPort);
	}
Example #8
0
void variant::increment_refcount()
{
	switch(type_) {
	case TYPE_LIST:
		++list_->refcount;
		break;
	case TYPE_STRING:
		++string_->refcount;
		break;
	case TYPE_CALLABLE:
		intrusive_ptr_add_ref(callable_);
		break;
	}
}
Example #9
0
 PoseEstimation::PoseEstimation()
     : Block()
     , m_ISDT("dT", 0.0f)
     , m_ISTime("time", 0.0f)
     , m_ISVelocityRate("velocityRate", Vec3f::Zero())
     , m_ISRotationRate("rotationRate", Vec3f::Zero())
     , m_ISMagneticField("magneticField", Vec3f::Zero())
     , m_ISAltitude("altitude", 0.0f)
     , m_OSAttitude("attitude", Attitude::Identity())
     , m_OSPosition("position", Vec3f::Zero())
     , m_OSVelocity("velocity", Vec3f::Zero())
     , m_OSEarthMagneticField("earthMagneticField", Vec3f::Zero())
 {
     intrusive_ptr_add_ref(&m_ISDT); addInputPort(&m_ISDT);
     intrusive_ptr_add_ref(&m_ISTime); addInputPort(&m_ISTime);
     intrusive_ptr_add_ref(&m_ISVelocityRate); addInputPort(&m_ISVelocityRate);
     intrusive_ptr_add_ref(&m_ISRotationRate); addInputPort(&m_ISRotationRate);
     intrusive_ptr_add_ref(&m_ISMagneticField); addInputPort(&m_ISMagneticField);
     intrusive_ptr_add_ref(&m_ISAltitude); addInputPort(&m_ISAltitude);
     intrusive_ptr_add_ref(&m_OSAttitude); addOutputPort(&m_OSAttitude);
     intrusive_ptr_add_ref(&m_OSPosition); addOutputPort(&m_OSPosition);
     intrusive_ptr_add_ref(&m_OSVelocity); addOutputPort(&m_OSVelocity);
     intrusive_ptr_add_ref(&m_OSEarthMagneticField); addOutputPort(&m_OSEarthMagneticField);
 }
Example #10
0
	thread::thread(function<void()> const &cb) :
		d(new thread::data)
	{
		d->shared=new win_thread_data(cb);

		uintptr_t p=_beginthreadex(0,0,booster_real_thread_func,d->shared.get(),0,0);
		if(p!=0) {
			// we want to transfer ownership to the thread explicitly
			intrusive_ptr_add_ref(d->shared.get());
		}
		else {
			throw system::system_error(system::error_code(errno,system::system_category));
		}
		
		d->h=(HANDLE)(p);
	}
Example #11
0
 PositionControl::PositionControl()
     : Block()
     , m_ISDT("dT", 0.0f)
     , m_ISAttitudeEstimated("attitudeEstimated", Attitude::Identity())
     , m_ISPositionEstimated("positionEstimated", Vec3f::Zero())
     , m_ISVelocityEstimated("velocityEstimated", Vec3f::Zero())
     , m_ISThrustControl("thrustControl", 0.0f)
     , m_ISDirectionControl("directionControl", Vec3f::Zero())
     , m_OSThrustSetpoint("thrustSetpoint", 0.0f)
     , m_OSAttitudeSetpoint("attitudeSetpoint", Attitude::Identity())
 {
     intrusive_ptr_add_ref(&m_ISDT); addInputPort(&m_ISDT);
     intrusive_ptr_add_ref(&m_ISAttitudeEstimated); addInputPort(&m_ISAttitudeEstimated);
     intrusive_ptr_add_ref(&m_ISPositionEstimated); addInputPort(&m_ISPositionEstimated);
     intrusive_ptr_add_ref(&m_ISVelocityEstimated); addInputPort(&m_ISVelocityEstimated);
     
     intrusive_ptr_add_ref(&m_ISThrustControl); addInputPort(&m_ISThrustControl);
     intrusive_ptr_add_ref(&m_ISDirectionControl); addInputPort(&m_ISDirectionControl);
     
     intrusive_ptr_add_ref(&m_OSThrustSetpoint); addOutputPort(&m_OSThrustSetpoint);
     intrusive_ptr_add_ref(&m_OSAttitudeSetpoint); addOutputPort(&m_OSAttitudeSetpoint);
 }
Example #12
0
  friend void push(sink& s, buffer p) {
    v4l2_buffer b = {0};
    b.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
    b.memory = V4L2_MEMORY_MMAP;
    b.index = p.get() - s.p->buffers;

    if(ioctl(s.p->fd.native_handle(), VIDIOC_QBUF, &b)) throw std::system_error(errno, std::system_category());
    intrusive_ptr_add_ref(p.get());

    if(atomic_exchange(&s.p->streaming, true)) {
      auto dqbuf = std::make_unique<v4l2_buffer>();
      memset(dqbuf.get(), 0, sizeof(*dqbuf.get()));
      dqbuf->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
      dqbuf->memory = V4L2_MEMORY_MMAP;
      auto dqp = dqbuf.get();

      s.p->fd.async_read_some(utils::make_ioctl_read_buffer<VIDIOC_DQBUF>(dqp), [&s, buffer = utils::move_on_copy(std::move(dqbuf))](std::error_code const& ec, std::size_t) {
        if(!ec) 
          intrusive_ptr_release(s.p->buffers + unwrap(buffer)->index);
      });
    }
  }
Example #13
0
void variant::increment_refcount()
{
	switch(type_) {
	case TYPE_LIST:
		++list_->refcount;
		break;
	case TYPE_STRING:
		++string_->refcount;
		break;
	case TYPE_MAP:
		++map_->refcount;
		break;
	case TYPE_CALLABLE:
		intrusive_ptr_add_ref(callable_);
		break;

	// These are not used here, add them to silence a compiler warning.
	case TYPE_NULL:
	case TYPE_DECIMAL:
	case TYPE_INT :
		break;
	}
}
Example #14
0
void intrusive_ptr_add_ref(AnnotationValue * p)
{
	intrusive_ptr_add_ref(&(p->name));
}
	IntrusivePtr(T* _p = NULL) : ptr(NULL) {
		if(_p) {
			intrusive_ptr_add_ref(_p);
			ptr = _p;
		}
	}
 IntrusivePtr (T* ptr, bool add_ref = true)
     : m_ptr (ptr)
 {
     if (ptr && add_ref)
         intrusive_ptr_add_ref (m_ptr);
 }
Example #17
0
void multiplexer::runnable::intrusive_ptr_add_ref_impl() {
  intrusive_ptr_add_ref(this);
}
 IntrusivePtr (IntrusivePtr const& rhs)
     : m_ptr (rhs.m_ptr)
 {
     if (m_ptr)
         intrusive_ptr_add_ref (m_ptr);
 }
Example #19
0
 //!Constructor from related. Copies the internal pointer and if "p" is not
 //!zero calls intrusive_ptr_add_ref(get_pointer(p)). Does not throw
 template<class U> intrusive_ptr
    (intrusive_ptr<U, VP> const & rhs)
    :  m_ptr(rhs.get())
 {
    if(m_ptr != 0) intrusive_ptr_add_ref(ipcdetail::get_pointer(m_ptr));
 }
void intrusive_ptr_add_ref(AnnotationDefinition * p)
{
	intrusive_ptr_add_ref((Element *)p);
}
Example #21
0
 value_list_end_impl()
     : value_node(value::default_tag)
 {
     intrusive_ptr_add_ref(&instance);
     next_ = this;
 }
Example #22
0
 value_counted::value_counted(value_node* x)
     : value_base(x)
 {
     intrusive_ptr_add_ref(value_);
 }
 IntrusivePtr (IntrusivePtr<U> const& rhs)
     : m_ptr (rhs.get ())
 {
     if (m_ptr)
         intrusive_ptr_add_ref (m_ptr);
 }
Example #24
0
 value_nil_impl()
     : empty_value_impl(value::default_tag)
 {
     intrusive_ptr_add_ref(&instance);
     next_ = &value_list_end_impl::instance;
 }
Example #25
0
 //!Constructor. Copies pointer and if "p" is not zero and 
 //!"add_ref" is true calls intrusive_ptr_add_ref(get_pointer(p)).
 //!Does not throw
 intrusive_ptr(const pointer &p, bool add_ref = true): m_ptr(p)
 {
    if(m_ptr != 0 && add_ref) intrusive_ptr_add_ref(ipcdetail::get_pointer(m_ptr));
 }
Example #26
0
PyObject * PyPreprocessor_scanHeaders( PyPreprocessor * self, PyObject * args, PyObject * kwds )
{
    static char * kwlist[] = { "pp_ctx", "filename", NULL };

    PyObject * pObject = 0;
    PyObject * filename = 0;

    assert( self->pp );

    if ( !PyArg_ParseTupleAndKeywords( args, kwds, "OO", kwlist, &pObject, &filename ) )
        return NULL;

    if ( !pObject || ( (PyTypeObject *)PyObject_Type( pObject ) != &PyPreprocessingContextType ) )
    {
        PyErr_SetString( PyExc_Exception, "Invalid preprocessing context parameter." );
        return NULL;
    }

    PyPreprocessingContext const * ppContext( reinterpret_cast<PyPreprocessingContext *>( pObject ) );

    if ( filename && !PyUnicode_Check( filename ) )
    {
        PyErr_SetString( PyExc_Exception, "Expected a string as 'filename' parameter." );
        return NULL;
    }

    Headers headers;
    HeaderList missing;
    PyThreadState * _save;
    bool result;
    try
    {
        Py_UNBLOCK_THREADS
        result = self->pp->scanHeaders( *ppContext->ppContext, PyUnicode_AsUTF8( filename ), headers, missing );
    }
    catch ( std::runtime_error const & error )
    {
        Py_BLOCK_THREADS
        PyErr_SetString( PyExc_RuntimeError, error.what() );
        return NULL;
    }
    catch ( std::exception const & error )
    {
        Py_BLOCK_THREADS
        PyErr_SetString( PyExc_Exception, error.what() );
        return NULL;
    }
    catch ( ... )
    {
        Py_BLOCK_THREADS
        PyErr_SetString( PyExc_Exception, "Unhandled exception" );
        return NULL;
    }
    
    if ( !result )
    {
        Py_BLOCK_THREADS
        PyErr_SetString( PyExc_Exception, "Failed to preprocess file." );
        return NULL;
    }

    // Group result by dir.
    typedef std::vector<Header const *> HeaderPtrList;
    typedef std::unordered_map<Dir, HeaderPtrList> DirsAndHeaders;
    DirsAndHeaders dirsAndHeaders;
    for ( Header const & header : headers )
        dirsAndHeaders[ header.dir ].push_back( &header );

    Py_BLOCK_THREADS
    PyObject * dirsTuple = PyTuple_New( dirsAndHeaders.size() );
    std::size_t dirIndex( 0 );
    for ( DirsAndHeaders::value_type const & dirAndHeaders : dirsAndHeaders )
    {
        PyObject * headersInDirTuple = PyTuple_New( dirAndHeaders.second.size() );
        std::size_t headersInDirTupleIndex( 0 );
        for ( Header const * header : dirAndHeaders.second )
        {
            PyObject * headerEntry = PyTuple_New( 3 );
            PyTuple_SET_ITEM( headerEntry, 0, PyUnicode_FromStringAndSize( header->name.get().data(), header->name.get().size() ) );

            PyObject * const isRelative( header->relative ? Py_True : Py_False );
            Py_INCREF( isRelative );
            PyTuple_SET_ITEM( headerEntry, 1, isRelative );
        
            PyContentEntry * contentEntry( (PyContentEntry *)_PyObject_New( &PyContentEntryType ) );
            contentEntry->ptr = header->contentEntry.get();
            intrusive_ptr_add_ref( contentEntry->ptr );

            PyTuple_SET_ITEM( headerEntry, 2, (PyObject *)contentEntry );
            PyTuple_SET_ITEM( headersInDirTuple, headersInDirTupleIndex++, headerEntry );
        }
        PyObject * dirTuple = PyTuple_New( 2 );
        llvm::StringRef const dirStr( dirAndHeaders.first.get() );
        PyObject * dir = PyUnicode_FromStringAndSize( dirStr.data(), dirStr.size() );
        PyTuple_SET_ITEM( dirTuple, 0, dir );
        PyTuple_SET_ITEM( dirTuple, 1, headersInDirTuple );
        PyTuple_SET_ITEM( dirsTuple, dirIndex++, dirTuple );
    }

    PyObject * missingHeadersTuple = PyTuple_New( missing.size() );
    std::size_t missingIndex( 0 );
    for ( HeaderList::value_type const & missingHeader : missing )
    {
        PyObject * val = PyUnicode_FromStringAndSize( missingHeader.data(), missingHeader.size() );
        PyTuple_SET_ITEM( missingHeadersTuple, missingIndex++, val );
    }
    
    PyObject * resultTuple = PyTuple_New( 2 );
    PyTuple_SET_ITEM( resultTuple, 0, dirsTuple );
    PyTuple_SET_ITEM( resultTuple, 1, missingHeadersTuple );
    return resultTuple;
}
Example #27
0
 //!Copy constructor. Copies the internal pointer and if "p" is not
 //!zero calls intrusive_ptr_add_ref(get_pointer(p)). Does not throw
 intrusive_ptr(intrusive_ptr const & rhs)
    :  m_ptr(rhs.m_ptr)
 {
    if(m_ptr != 0) intrusive_ptr_add_ref(ipcdetail::get_pointer(m_ptr));
 }
boost::shared_ptr<T> shared_from_intrusive(T * p)
{
  if(p) intrusive_ptr_add_ref(p);
  return boost::shared_ptr<T>(p, intrusive_deleter<T>());
}
Example #29
0
 value_counted::value_counted(value_base const& x)
     : value_base(x)
 {
     intrusive_ptr_add_ref(value_);
 }
Example #30
0
 static void addref(Component* component)
 {
     intrusive_ptr_add_ref(component);
 }