void FabricTimeController::RefreshAndPersistCompletedCallback(AsyncOperationSPtr const & operation, bool setReady, bool completedSynchronously, ActivityId activityId) { if (operation->CompletedSynchronously == completedSynchronously) { ErrorCode error=StoreTransactionInternal::EndCommit(operation); if(error.IsSuccess()) { if(setReady) { ready_=true; } } else { WriteWarning(TraceComponent,"{0} Fail to read logical time in replicated store. Error:{1}, Activity:{2}",this->TraceId,error,activityId); } if(error.IsError(ErrorCodeValue::Timeout)) { TryScheduleTimer(StoreConfig::GetConfig().FabricTimeRefreshTimeoutValue); } else { TryScheduleTimer(StoreConfig::GetConfig().FabricTimePersistInterval); } } }
ErrorCode ReplicatedStore::TransactionBase::CheckAborted() { if (aborted_.load()) { WriteWarning( TraceComponent, "{0} transaction aborted: forced={1}", this->TraceId, isForceReleased_); return isForceReleased_ ? ErrorCodeValue::NotPrimary : ErrorCodeValue::TransactionAborted; } else { return ErrorCodeValue::Success; } }
void CheckGLError(const char* op) { #if defined (UTH_SYSTEM_ANDROID) EGLint error = eglGetError(); if (error != EGL_SUCCESS) { WriteWarning("EGL Function Failed: %d\n", error); } #else for (GLint error = glGetError(); error; error = glGetError()) { WriteError("after %s() glError (0x%x)", op, error); } #endif }
void asCBuilder::CompileClasses() { asUINT n; asCArray<sClassDeclaration*> toValidate; // Go through each of the classes and register the object type descriptions for( n = 0; n < classDeclarations.GetLength(); n++ ) { sClassDeclaration *decl = classDeclarations[n]; // Enumerate each of the declared properties asCScriptNode *node = decl->node->firstChild->next; // Skip list of classes and interfaces while( node && node->nodeType == snIdentifier ) node = node->next; while( node ) { if( node->nodeType == snDeclaration ) { asCScriptCode *file = decl->script; asCDataType dt = CreateDataTypeFromNode(node->firstChild, file); GETSTRING(name, &file->code[node->lastChild->tokenPos], node->lastChild->tokenLength); if( dt.IsReadOnly() ) { int r, c; file->ConvertPosToRowCol(node->tokenPos, &r, &c); WriteError(file->name.AddressOf(), TXT_PROPERTY_CANT_BE_CONST, r, c); } asCDataType st; st.SetObjectType(decl->objType); CheckNameConflictMember(st, name.AddressOf(), node->lastChild, file); // Store the properties in the object type descriptor asCProperty *prop = new asCProperty; prop->name = name; prop->type = dt; int propSize; if( dt.IsObject() ) { propSize = dt.GetSizeOnStackDWords()*4; if( !dt.IsObjectHandle() ) { if( dt.GetSizeInMemoryBytes() == 0 ) { int r, c; file->ConvertPosToRowCol(node->tokenPos, &r, &c); asCString str; str.Format(TXT_DATA_TYPE_CANT_BE_s, dt.Format().AddressOf()); WriteError(file->name.AddressOf(), str.AddressOf(), r, c); } prop->type.MakeReference(true); } } else { propSize = dt.GetSizeInMemoryBytes(); if( propSize == 0 ) { int r, c; file->ConvertPosToRowCol(node->tokenPos, &r, &c); asCString str; str.Format(TXT_DATA_TYPE_CANT_BE_s, dt.Format()); WriteError(file->name.AddressOf(), str.AddressOf(), r, c); } } // Add extra bytes so that the property will be properly aligned if( propSize == 2 && (decl->objType->size & 1) ) decl->objType->size += 1; if( propSize > 2 && (decl->objType->size & 3) ) decl->objType->size += 3 - (decl->objType->size & 3); prop->byteOffset = decl->objType->size; decl->objType->size += propSize; decl->objType->properties.PushLast(prop); // Make sure the module holds a reference to the config group where the object is registered module->RefConfigGroupForObjectType(dt.GetObjectType()); } else if( node->nodeType == snFunction ) { // TODO: Register the method and add it to the list of functions to compile later } else assert(false); node = node->next; } toValidate.PushLast(decl); } // Verify that the declared structures are valid, e.g. that the structure // doesn't contain a member of its own type directly or indirectly while( toValidate.GetLength() > 0 ) { asUINT numClasses = (asUINT)toValidate.GetLength(); asCArray<sClassDeclaration*> toValidateNext; while( toValidate.GetLength() > 0 ) { sClassDeclaration *decl = toValidate[toValidate.GetLength()-1]; int validState = 1; for( asUINT n = 0; n < decl->objType->properties.GetLength(); n++ ) { // A valid structure is one that uses only primitives or other valid objects asCProperty *prop = decl->objType->properties[n]; asCDataType dt = prop->type; if( dt.IsScriptArray() ) { asCDataType sub = dt; while( sub.IsScriptArray() && !sub.IsObjectHandle() ) sub = sub.GetSubType(); dt = sub; } if( dt.IsObject() && !dt.IsObjectHandle() ) { // Find the class declaration sClassDeclaration *pdecl = 0; for( asUINT p = 0; p < classDeclarations.GetLength(); p++ ) { if( classDeclarations[p]->objType == dt.GetObjectType() ) { pdecl = classDeclarations[p]; break; } } if( pdecl ) { if( pdecl->objType == decl->objType ) { int r, c; decl->script->ConvertPosToRowCol(decl->node->tokenPos, &r, &c); WriteError(decl->script->name.AddressOf(), TXT_ILLEGAL_MEMBER_TYPE, r, c); validState = 2; break; } else if( pdecl->validState != 1 ) { validState = pdecl->validState; break; } } } } if( validState == 1 ) { decl->validState = 1; toValidate.PopLast(); } else if( validState == 2 ) { decl->validState = 2; toValidate.PopLast(); } else { toValidateNext.PushLast(toValidate.PopLast()); } } toValidate = toValidateNext; toValidateNext.SetLength(0); if( numClasses == toValidate.GetLength() ) { int r, c; toValidate[0]->script->ConvertPosToRowCol(toValidate[0]->node->tokenPos, &r, &c); WriteError(toValidate[0]->script->name.AddressOf(), TXT_ILLEGAL_MEMBER_TYPE, r, c); break; } } if( numErrors > 0 ) return; // TODO: The declarations form a graph, all circles in // the graph must be flagged as potential circles // Verify potential circular references for( n = 0; n < classDeclarations.GetLength(); n++ ) { sClassDeclaration *decl = classDeclarations[n]; asCObjectType *ot = decl->objType; // Is there some path in which this structure is involved in circular references? for( asUINT p = 0; p < ot->properties.GetLength(); p++ ) { asCDataType dt = ot->properties[p]->type; if( dt.IsObject() ) { // Any structure that contains an any type can generate circular references if( dt.GetObjectType()->flags & asOBJ_CONTAINS_ANY ) { ot->flags |= asOBJ_POTENTIAL_CIRCLE | asOBJ_CONTAINS_ANY; } if( dt.IsObjectHandle() ) { // TODO: // Can this handle really generate a circular reference ot->flags |= asOBJ_POTENTIAL_CIRCLE; } else if( dt.GetObjectType()->flags & asOBJ_POTENTIAL_CIRCLE ) { // TODO: // Just because the member type is a potential circle doesn't mean that this one is ot->flags |= asOBJ_POTENTIAL_CIRCLE; } if( dt.IsArrayType() ) { asCDataType sub = dt.GetSubType(); while( sub.IsObject() ) { if( sub.IsObjectHandle() || (sub.GetObjectType()->flags & asOBJ_POTENTIAL_CIRCLE) ) { decl->objType->flags |= asOBJ_POTENTIAL_CIRCLE; // Make sure the array object is also marked as potential circle sub = dt; while( sub.IsScriptArray() ) { sub.GetObjectType()->flags |= asOBJ_POTENTIAL_CIRCLE; sub = sub.GetSubType(); } break; } if( sub.IsScriptArray() ) sub = sub.GetSubType(); else break; } } } } } // Verify that the class implements all the methods from the interfaces it implements for( n = 0; n < classDeclarations.GetLength(); n++ ) { sClassDeclaration *decl = classDeclarations[n]; asCScriptCode *file = decl->script; // Enumerate each of the implemented interfaces asCScriptNode *node = decl->node->firstChild->next; while( node && node->nodeType == snIdentifier ) { // Get the interface name from the node GETSTRING(name, &file->code[node->tokenPos], node->tokenLength); // Find the object type for the interface asCObjectType *objType = GetObjectType(name.AddressOf()); if( decl->objType->Implements(objType) ) { int r, c; file->ConvertPosToRowCol(node->tokenPos, &r, &c); WriteWarning(file->name.AddressOf(), TXT_INTERFACE_ALREADY_IMPLEMENTED, r, c); } else { decl->objType->interfaces.PushLast(objType); // Make sure all the methods of the interface are implemented for( asUINT i = 0; i < objType->methods.GetLength(); i++ ) { if( !DoesMethodExist(decl->objType, objType->methods[i]) ) { int r, c; file->ConvertPosToRowCol(decl->node->tokenPos, &r, &c); asCString str; str.Format(TXT_MISSING_IMPLEMENTATION_OF_s, engine->GetFunctionDeclaration(objType->methods[i]).AddressOf()); WriteError(file->name.AddressOf(), str.AddressOf(), r, c); } } } node = node->next; } } }
void asCBuilder::ParseScripts() { asCArray<asCParser*> parsers; // Parse all the files as if they were one asUINT n = 0; for( n = 0; n < scripts.GetLength(); n++ ) { asCParser *parser = new asCParser(this); parsers.PushLast(parser); // Parse the script file parser->ParseScript(scripts[n]); } if( numErrors == 0 ) { // Find all type declarations for( n = 0; n < scripts.GetLength(); n++ ) { asCScriptNode *node = parsers[n]->GetScriptNode(); // Find structure definitions first node = node->firstChild; while( node ) { asCScriptNode *next = node->next; if( node->nodeType == snClass ) { node->DisconnectParent(); RegisterClass(node, scripts[n]); } else if( node->nodeType == snInterface ) { node->DisconnectParent(); RegisterInterface(node, scripts[n]); } node = next; } } // Register script methods found in the structures for( n = 0; n < classDeclarations.GetLength(); n++ ) { sClassDeclaration *decl = classDeclarations[n]; asCScriptNode *node = decl->node->firstChild->next; // Skip list of classes and interfaces while( node && node->nodeType == snIdentifier ) node = node->next; while( node ) { asCScriptNode *next = node->next; if( node->nodeType == snFunction ) { node->DisconnectParent(); RegisterScriptFunction(module->GetNextFunctionId(), node, decl->script, decl->objType); } node = next; } // Make sure the default constructor exists for classes if( decl->objType->beh.construct == engine->scriptTypeBehaviours.beh.construct ) { AddDefaultConstructor(decl->objType, decl->script); } } // Register script methods found in the interfaces for( n = 0; n < interfaceDeclarations.GetLength(); n++ ) { sClassDeclaration *decl = interfaceDeclarations[n]; asCScriptNode *node = decl->node->firstChild->next; while( node ) { asCScriptNode *next = node->next; if( node->nodeType == snFunction ) { node->DisconnectParent(); RegisterScriptFunction(module->GetNextFunctionId(), node, decl->script, decl->objType, true); } node = next; } } // Find other global nodes for( n = 0; n < scripts.GetLength(); n++ ) { // Find other global nodes asCScriptNode *node = parsers[n]->GetScriptNode(); node = node->firstChild; while( node ) { asCScriptNode *next = node->next; node->DisconnectParent(); if( node->nodeType == snFunction ) { RegisterScriptFunction(module->GetNextFunctionId(), node, scripts[n]); } else if( node->nodeType == snGlobalVar ) { RegisterGlobalVar(node, scripts[n]); } else if( node->nodeType == snImport ) { RegisterImportedFunction(module->GetNextImportedFunctionId(), node, scripts[n]); } else { // Unused script node int r, c; scripts[n]->ConvertPosToRowCol(node->tokenPos, &r, &c); WriteWarning(scripts[n]->name.AddressOf(), TXT_UNUSED_SCRIPT_NODE, r, c); delete node; } node = next; } } } for( n = 0; n < parsers.GetLength(); n++ ) delete parsers[n]; }
void asCBuilder::ParseScripts() { asCArray<asCParser*> parsers; // Parse all the files as if they were one asUINT n = 0; for( n = 0; n < scripts.GetLength(); n++ ) { asCParser *parser = new asCParser(this); parsers.PushLast(parser); // Parse the script file parser->ParseScript(scripts[n]); } if( numErrors == 0 ) { // Find all type declarations for( n = 0; n < scripts.GetLength(); n++ ) { asCScriptNode *node = parsers[n]->GetScriptNode(); // Find structure definitions first node = node->firstChild; while( node ) { asCScriptNode *next = node->next; if( node->nodeType == snStruct ) { node->DisconnectParent(); RegisterStruct(node, scripts[n]); } node = next; } } // Find other global nodes for( n = 0; n < scripts.GetLength(); n++ ) { // Find other global nodes asCScriptNode *node = parsers[n]->GetScriptNode(); node = node->firstChild; while( node ) { asCScriptNode *next = node->next; node->DisconnectParent(); if( node->nodeType == snFunction ) { RegisterScriptFunction(module->GetNextFunctionId(), node, scripts[n]); } else if( node->nodeType == snGlobalVar ) { RegisterGlobalVar(node, scripts[n]); } else if( node->nodeType == snImport ) { RegisterImportedFunction(module->GetNextImportedFunctionId(), node, scripts[n]); } else { // Unused script node int r, c; scripts[n]->ConvertPosToRowCol(node->tokenPos, &r, &c); WriteWarning(scripts[n]->name.AddressOf(), TXT_UNUSED_SCRIPT_NODE, r, c); delete node; } node = next; } } } for( n = 0; n < parsers.GetLength(); n++ ) delete parsers[n]; }
void FabricTimeController::RefreshAndPersist() { shared_ptr<ScopedActiveFlag> scopedActiveFlag; if (!ScopedActiveFlag::TryAcquire(refreshActive_, scopedActiveFlag)) { WriteInfo( TraceComponent, "{0} FabricTimeController refresh already active", this->TraceId); TryScheduleTimer(StoreConfig::GetConfig().FabricTimePersistInterval); return; } if (cancelled_.load()) { WriteInfo( TraceComponent, "{0} FabricTimeController refresh already cencelled", this->TraceId); refreshTimer_->Cancel(); return; } ActivityId activityId; StoreTransactionInternal tx=StoreTransactionInternal::Create(&replicatedStore_,replicatedStore_.PartitionedReplicaId,activityId); //if the controller is not ready, then initialize the controller if(!ready_) { //first time call ErrorCode error=tx.Exists(fabricTimeData_); if(error.IsError(ErrorCodeValue::NotFound)) { fabricTimeData_.RefreshAndGetCurrentStoreTime(); error=tx.Insert(fabricTimeData_); if(!error.IsSuccess()) { WriteWarning( TraceComponent, "{0} Fail to insert logical time in replicated store. Error:{1}, PartitionReplicaId:{2}, Activity:{3}", this->TraceId, error, PartitionedReplicaId, activityId); TryScheduleTimer(StoreConfig::GetConfig().FabricTimePersistInterval); return; } } //load logical time from store else { error=tx.ReadExact(fabricTimeData_); if(!error.IsSuccess()) { WriteWarning( TraceComponent, "{0} Fail to read logical time in replicated store. Error:{1}, PartitionReplicaId:{2}, Activity:{3}", this->TraceId, error, PartitionedReplicaId, activityId); TryScheduleTimer(StoreConfig::GetConfig().FabricTimePersistInterval); return; } } auto operation=StoreTransactionInternal::BeginCommit( std::move(tx), StoreConfig::GetConfig().FabricTimeRefreshTimeoutValue, [this,activityId](AsyncOperationSPtr const & operation) { RefreshAndPersistCompletedCallback(operation,true,false,activityId); }, this->CreateAsyncOperationRoot()); //Complete Synchronously RefreshAndPersistCompletedCallback(operation,true,true,activityId); } else { //refresh the value fabricTimeData_.RefreshAndGetCurrentStoreTime(); tx.Update(fabricTimeData_,false); auto componentRoot=this->CreateComponentRoot(); auto operation=StoreTransactionInternal::BeginCommit( std::move(tx), StoreConfig::GetConfig().FabricTimeRefreshTimeoutValue, [componentRoot,this,activityId](AsyncOperationSPtr const & operation) { RefreshAndPersistCompletedCallback(operation,false,false,activityId); }, this->CreateAsyncOperationRoot()); //Complete Synchronously RefreshAndPersistCompletedCallback(operation,false,true,activityId); } }