Esempio n. 1
0
void ProxyEntity::invalidated(ProxyObjectPtr ptr, bool permanent)
{
    mScene->renderStrand()->post(
        std::tr1::bind(&ProxyEntity::iInvalidated,this,
            ptr,permanent,livenessToken()),
        "ProxyEntity::iInvalidated");
}
Esempio n. 2
0
void ProxyEntity::destroyed(ProxyObjectPtr ptr)
{
    mScene->renderStrand()->post(
        std::tr1::bind(&ProxyEntity::iDestroyed,
            this,ptr,livenessToken()),
            "ProxyEntity::iDestroyed");
}
Esempio n. 3
0
void ProxyEntity::onSetMesh (
    ProxyObjectPtr proxy, Transfer::URI const& meshFile,
    const SpaceObjectReference& sporef )
{
    mScene->renderStrand()->post(
        std::tr1::bind(&ProxyEntity::iOnSetMesh,this,
            proxy,meshFile,sporef,livenessToken()));
}
Esempio n. 4
0
void ProxyEntity::onSetScale (
    ProxyObjectPtr proxy, float32 scale,
    const SpaceObjectReference& sporef )
{
    mScene->renderStrand()->post(
        std::tr1::bind(&ProxyEntity::iOnSetScale,this,
            proxy,scale,sporef,livenessToken()));
}
Esempio n. 5
0
v8::Handle<v8::Value> JSTimerStruct::clear()
{
    if (getIsCleared())
    {
        JSLOG(insane,"In JSTimerStruct, calling clear on a timer that has already been cleared.");
        return JSSuspendable::clear();
    }

    v8::HandleScope handle_scope;

    JSSuspendable::clear();

    mDeadlineTimer->cancel();

    if (! cb.IsEmpty())
        cb.Dispose();

    if (! mPersistentHandle.IsEmpty())
    {
        //check to make sure object has adequate number of fields.
        CHECK_INTERNAL_FIELD_COUNT(mPersistentHandle,jstimer,TIMER_JSTIMER_TEMPLATE_FIELD_COUNT, v8::Boolean::New(true));

        //delete typeId, and return if have incorrect params for type id
        DEL_TYPEID_AND_CHECK(mPersistentHandle,jstimer,TIMER_TYPEID_STRING,v8::Boolean::New(true));

        mPersistentHandle->SetInternalField(TIMER_JSTIMERSTRUCT_FIELD, External::New(NULL));
    }

    // Be careful after this! JSContextStruct::struct_deregisterSuspendable will
    // delete this object so you shouldn't use any member variables after
    // invoking it.
    if (jsContStruct != NULL)
    {
        //cannot clear if amExecuting.
        if (amExecuting)
        {
            mCtx->objStrand->post(
                std::tr1::bind(&JSContextStruct::struct_asyncDeregisterSuspendable,jsContStruct,this,
                    jsContStruct->livenessToken(),livenessToken()),
                "JSContextStruct::struct_asyncDeregisterSuspendable"
            );
        }
        else
            jsContStruct->struct_deregisterSuspendable(this);
    }

    // Note that since this allows the JS GC thread to destroy this object
    // in response to all references to it being lost,
    // we need to make sure it is absolutely the *last* operation we do on
    // member variables.
    // In this case, the above call will have deleted this JSTimerStruct, so we
    // don't even set it at all. It would have been unsafe to set it earlier
    // because we could have ended up with two threads trying to do the deletion.
    //noTimerWaiting = true;

    return v8::Boolean::New(true);
}
Esempio n. 6
0
void ProxyEntity::updateLocation(
    ProxyObjectPtr proxy, const TimedMotionVector3f &newLocation,
    const TimedMotionQuaternion& newOrient, const BoundingSphere3f& newBounds,
    const SpaceObjectReference& sporef)
{
    mScene->renderStrand()->post(
        std::tr1::bind(&ProxyEntity::iUpdateLocation,this,
            proxy,newLocation,newOrient,newBounds,sporef,livenessToken()),
        "ProxyEntity::iUpdateLocation");
}
Esempio n. 7
0
void ProxyEntity::handleDestroyTimeout()
{
    assert(mProxy);
    assert(mActive);

    mScene->renderStrand()->post(
        std::tr1::bind(&ProxyEntity::iHandleDestroyTimeout,
            this,livenessToken()),
            "ProxyEntity::iHandleDestroyTimeout");
}
Esempio n. 8
0
void JSTimerStruct::fixSuspendableToContext(JSContextStruct* toAttachTo)
{
    jsContStruct = toAttachTo;

    noTimerWaiting=false;
    if (mTimeRemaining == 0)
    {
        mDeadlineTimer->wait(
            timeUntil,std::tr1::bind(
                &JSTimerStruct::evaluateCallback,this,livenessToken()));
    }
    else
    {
        mDeadlineTimer->wait(
            Duration::microseconds(mTimeRemaining*1000000),
            std::tr1::bind(&JSTimerStruct::evaluateCallback,this,livenessToken()));
    }

    jsContStruct->struct_registerSuspendable(this);
}
Esempio n. 9
0
v8::Handle<v8::Value> JSTimerStruct::struct_resetTimer(double timeInSecondsToRefire)
{
    if (getIsCleared())
    {
        JSLOG(info,"Error in JSTimerStruct.  Calling reset on a timer that has already been cleared.");
        return JSSuspendable::clear();
    }

    mDeadlineTimer->cancel();
    noTimerWaiting=false;
    mDeadlineTimer->wait(
        Duration::seconds(timeInSecondsToRefire),
        std::tr1::bind(&JSTimerStruct::evaluateCallback,this, livenessToken()));

    return JSSuspendable::resume();
}
Esempio n. 10
0
//has more of a reset-type functionality than resume
//if the time has not been cleared, then, cancel the current timer,
//and start a new countdown to execute the callback.
v8::Handle<v8::Value> JSTimerStruct::resume()
{
    if (getIsCleared())
    {
        JSLOG(info,"Error in JSTimerStruct.  Trying to resume a timer object that has already been cleared.  Taking no action");
        return JSSuspendable::getIsSuspendedV8();
    }
    mDeadlineTimer->cancel();

    noTimerWaiting=false;
    mDeadlineTimer->wait(
        timeUntil,std::tr1::bind(
            &JSTimerStruct::evaluateCallback,this,livenessToken()));

    return JSSuspendable::resume();
}
Esempio n. 11
0
void ReplicatedLocationServiceCache::orientationUpdated(const ObjectReference& uuid, const TimedMotionQuaternion& newval, uint64 seqno) {
    Lock lck(mMutex);

    ObjectDataMap::iterator it = mObjects.find(uuid);
    if (it == mObjects.end()) return;

    it->second.props.setOrientation(newval, seqno);

    bool agg = it->second.aggregate;

    it->second.tracking++;
    mStrand->post(
        std::tr1::bind(
            &ReplicatedLocationServiceCache::notifyOrientationUpdated, this, livenessToken(), uuid
        )
    );
}
Esempio n. 12
0
void ReplicatedLocationServiceCache::physicsUpdated(const ObjectReference& uuid, const String& newval, uint64 seqno) {
    Lock lck(mMutex);

    ObjectDataMap::iterator it = mObjects.find(uuid);
    if (it == mObjects.end()) return;
    String oldval = it->second.props.physics();
    it->second.props.setPhysics(newval, seqno);

    bool agg = it->second.aggregate;

    it->second.tracking++;
    mStrand->post(
        std::tr1::bind(
            &ReplicatedLocationServiceCache::notifyPhysicsUpdated, this, livenessToken(), uuid
        )
    );
}
Esempio n. 13
0
void ReplicatedLocationServiceCache::parentUpdated(const ObjectReference& uuid, const ObjectReference& newval, uint64 seqno) {
    Lock lck(mMutex);

    ObjectDataMap::iterator it = mObjects.find(uuid);
    if (it == mObjects.end()) return;
    ObjectReference oldval = it->second.parent;
    it->second.parent = newval; // FIXME seqno?

    bool agg = it->second.aggregate;

    it->second.tracking++;
    mStrand->post(
        std::tr1::bind(
            &ReplicatedLocationServiceCache::notifyParentUpdated, this, livenessToken(), uuid, oldval, newval
        )
    );
}
Esempio n. 14
0
void ReplicatedLocationServiceCache::epochUpdated(const ObjectReference& uuid, const uint64 ep) {
    Lock lck(mMutex);

    ObjectDataMap::iterator it = mObjects.find(uuid);
    if (it == mObjects.end()) return;

    it->second.epoch = std::max(it->second.epoch, ep);

    bool agg = it->second.aggregate;

    it->second.tracking++;
    mStrand->post(
        std::tr1::bind(
            &ReplicatedLocationServiceCache::notifyEpochUpdated, this,
            livenessToken(),
            uuid, ep
        ),
        "ReplicatedLocationServiceCache::notifyEpochUpdated"
    );
}
Esempio n. 15
0
void ReplicatedLocationServiceCache::objectRemoved(const ObjectReference& uuid, bool temporary) {
    Lock lck(mMutex);

    ObjectDataMap::iterator data_it = mObjects.find(uuid);
    if (data_it == mObjects.end()) return;

    assert(data_it->second.exists);
    data_it->second.exists = false;
    bool agg = data_it->second.aggregate;

    data_it->second.tracking++;
    mStrand->post(
        std::tr1::bind(
            &ReplicatedLocationServiceCache::notifyObjectRemoved, this,
            livenessToken(),
            uuid, temporary
        ),
        "ReplicatedLocationServiceCache::notifyObjectRemoved"
    );
}
Esempio n. 16
0
void ReplicatedLocationServiceCache::boundsUpdated(const ObjectReference& uuid, const AggregateBoundingInfo& newval, uint64 seqno) {
    Lock lck(mMutex);

    ObjectDataMap::iterator it = mObjects.find(uuid);
    if (it == mObjects.end()) return;

    AggregateBoundingInfo oldval = it->second.props.bounds();
    it->second.props.setBounds(newval, seqno);

    bool agg = it->second.aggregate;

    it->second.tracking++;
    mStrand->post(
        std::tr1::bind(
            &ReplicatedLocationServiceCache::notifyBoundsUpdated, this,
            livenessToken(),
            uuid, oldval, newval
        ),
        "ReplicatedLocationServiceCache::notifyBoundsUpdated"
    );
}
Esempio n. 17
0
void JSTimerStruct::iEvaluateCallback(Liveness::Token token)
{
    //lkjs; FIXME: Can weak reference clean up a timer
    //while it's in this function?  (If we try to use lock, we run
    //into a problem when the timer tries to clear itself.)
    if (!token)
        return;

    if (mCtx->stopped()) {
        JSLOG(warn, "Timer evaluateCallback invoked after stop request, ignoring...");
        noTimerWaiting=true; // Allow cleanup, see notes below
        return;
    }


    while(!mCtx->initialized())
    {}
    amExecuting = true;
    emerScript->invokeCallbackInContext(emerScript->livenessToken(), cb, jsContStruct);


    //if we were told to kill the timer after firing, then check kill conditions
    //again in noReference.
    if (killAfterFire)
    {
        mCtx->objStrand->post(
            std::tr1::bind(&JSTimerStruct::noReference,this,
                livenessToken()),
            "JSTimerStruct::noReference"
        );
    }

    //means that we have no pending timer operation.
    // Note that since this allows the JS GC thread to destroy this object
    // in response to all references to it being lost,
    // we need to make sure it is absolutely the *last* operation we do on
    // member variables.
    noTimerWaiting=true;
    amExecuting = false;
}
Esempio n. 18
0
void ReplicatedLocationServiceCache::objectAdded(
    const ObjectReference& uuid, bool agg,
    const ObjectReference& parent,
    const TimedMotionVector3f& loc, uint64 loc_seqno,
    const TimedMotionQuaternion& orient, uint64 orient_seqno,
    const AggregateBoundingInfo& bounds, uint64 bounds_seqno,
    const Transfer::URI& mesh, uint64 mesh_seqno,
    const String& physics, uint64 physics_seqno
) {
    Lock lck(mMutex);

    ObjectDataMap::iterator it = mObjects.find(uuid);
    assert(it == mObjects.end() || (it->second.exists == false));

    if (it == mObjects.end())
        it = mObjects.insert( ObjectDataMap::value_type(uuid, ObjectData()) ).first;
    else
        it->second.props = SequencedPresenceProperties(); // reset
    it->second.exists = true;
    it->second.props.setLocation(loc, loc_seqno);
    it->second.props.setOrientation(orient, orient_seqno);
    it->second.props.setBounds(bounds, bounds_seqno);
    it->second.props.setMesh(mesh, mesh_seqno);
    it->second.props.setPhysics(physics, physics_seqno);
    it->second.aggregate = agg;
    it->second.parent = parent;


    it->second.tracking++;
    mStrand->post(
        std::tr1::bind(
            &ReplicatedLocationServiceCache::notifyObjectAdded, this,
            livenessToken(),
            uuid, parent, agg, loc, bounds
        ),
        "ReplicatedLocationServiceCache::notifyObjectAdded"
    );
}
Esempio n. 19
0
void ProxyEntity::onSetIsAggregate (ProxyObjectPtr proxy, bool isAgg,const SpaceObjectReference& sporef)
{
  mScene->renderStrand()->post(
        std::tr1::bind(&ProxyEntity::iOnSetIsAggregate,this,
            proxy,isAgg,sporef,livenessToken()));
}