public void BeginWrite(long which) { RE.MaybeSwitch(); RE.Assert(!_reading.Contains(which), $"Read in progress during write at {which}"); RE.Assert(!_writing.Contains(which), $"Write in progress during write at {which}"); _writing.Add(which); }
private static void WaitWhileOccupied(ReadIndicator readIndicator) { while (!readIndicator.IsEmpty) { RE.Yield(); } }
internal void EnterWriteLock() { RMonitor.Enter(_lockObj); RUnordered.Write(ref _writerActive, 1); RInterlocked.MemoryBarrierProcessWide(); while (ReadInProgress()) { RE.Yield(); } _snoop.BeginWrite(); return; }
private void EnterSlow() { RMonitor.Enter(_lockObj); RUnordered.Write(ref _holdingThreadId, Environment.CurrentManagedThreadId); RInterlocked.MemoryBarrierProcessWide(); while (RUnordered.Read(ref _isHeld) == 1) { RE.Yield(); } RUnordered.Write(ref _isHeld, 1); RMonitor.Exit(_lockObj); return; }
protected override void OnDefineLexer(Lexicon lexicon, ICollection <Token> triviaTokens) { var lexer = lexicon.Lexer; PLUS = lexer.DefineToken(RE.Symbol('+')); ASTERISK = lexer.DefineToken(RE.Symbol('*')); LEFT_PARENTHESIS = lexer.DefineToken(RE.Symbol('(')); RIGHT_PARENTHESIS = lexer.DefineToken(RE.Symbol(')')); NUMBER = lexer.DefineToken(RE.Range('0', '9').Many1(), "number"); SPACE = lexer.DefineToken(RE.Symbol(' ').Many1()); triviaTokens.Add(SPACE); }
private LockCookie EnterSlow() { RMonitor.Enter(_lockObj); var oldEntry = RUnordered.Read(ref _current); RUnordered.Write(ref _current, new LockCookie(Environment.CurrentManagedThreadId)); RInterlocked.MemoryBarrierProcessWide(); while (oldEntry != null && RUnordered.Read(ref oldEntry.Taken) == 1) { RE.Yield(); } var current = RUnordered.Read(ref _current); RUnordered.Write(ref current.Taken, 1); RMonitor.Exit(_lockObj); return(current); }
public ActionResult <RE <LoginResponse> > Login(LoginRequest request) { var response = new RE <LoginResponse>(); try { var user = _userService.Authenticate(request); if (user == null) { return(Unauthorized()); } var r = new LoginResponse(); r.credidentals = new Credidentals() { access_token = user.authToken, token_type = "Bearer" }; //automap r.user = new Models.LoginUser() { id = user.id.ToString(), userName = user.username }; response.data = r; response.code = Ok().StatusCode; } catch (Error ex) { var re = response.Exception(ex); return(BadRequest()); } catch (Exception ex) { return(response.Exception(ex)); } return(response); }
public void EndRead(long which) { RE.MaybeSwitch(); _reading.Remove(which); RE.Assert(!_writing.Contains(which), $"Write in progress during read at {which}"); }
/// <summary> /// Divides the left operand from the right one. /// </summary> /// <param name="Left">Left operand.</param> /// <param name="Right">Right operand.</param> /// <param name="Node">Node performing the operation.</param> /// <returns>Result</returns> public static IElement EvaluateDivision(IElement Left, IElement Right, ScriptNode Node) { IElement Result; IRingElement Temp; if (Left is IRingElement LE && !(!(Right is IRingElement RE))) { // TODO: Optimize in case of matrices. It's more efficient to employ a solve algorithm than to compute the inverse and the multiply. Temp = LE.Invert(); if (!(Temp is null)) { Result = RE.MultiplyLeft(Temp); if (!(Result is null)) { return(Result); } Result = Temp.MultiplyRight(RE); if (!(Result is null)) { return(Result); } } } if (Left.IsScalar) { if (Right.IsScalar) { ISet LeftSet = Left.AssociatedSet; ISet RightSet = Right.AssociatedSet; if (!LeftSet.Equals(RightSet)) { if (!Expression.UpgradeField(ref Left, ref LeftSet, ref Right, ref RightSet, Node)) { throw new ScriptRuntimeException("Incompatible operands.", Node); } LE = Left as IRingElement; RE = Right as IRingElement; if (!(LE is null) && !(RE is null)) { Temp = LE.Invert(); if (!(Temp is null)) { Result = RE.MultiplyLeft(Temp); if (!(Result is null)) { return(Result); } Result = Temp.MultiplyRight(RE); if (!(Result is null)) { return(Result); } } } } throw new ScriptRuntimeException("Operands cannot be divided.", Node); } else { LinkedList <IElement> Elements = new LinkedList <IElement>(); foreach (IElement RightChild in Right.ChildElements) { Elements.AddLast(EvaluateDivision(Left, RightChild, Node)); } return(Right.Encapsulate(Elements, Node)); } } else { if (Right.IsScalar) { LinkedList <IElement> Elements = new LinkedList <IElement>(); foreach (IElement LeftChild in Left.ChildElements) { Elements.AddLast(EvaluateDivision(LeftChild, Right, Node)); } return(Left.Encapsulate(Elements, Node)); } else { if (Left is ISet Set1 && !(!(Right is ISet Set2))) { return(new SetDifference(Set1, Set2)); }
public virtual Cmd VisitRE(RE node) { Contract.Requires(node != null); Contract.Ensures(Contract.Result <Cmd>() != null); return((Cmd)this.Visit(node)); // Call general visit so subtypes get visited by their particular visitor }
public void BeginWrite() { _writeInProgress = true; RE.Assert(_numReaders == 0, $"Write in progress with {_numReaders} readers!"); }
public void BeginRead() { _numReaders++; RE.Assert(!_writeInProgress, $"Write in progress with {_numReaders} readers!"); }
public override Cmd VisitRE(RE node) { throw new NotImplementedException(); }
public string Generate(string code) { var match = RE.Match(code); return(match.Groups[1].Value + ".cs"); }
public override IEnumerable <ProductionRuleToken> GetTokens() { IEnumerable <ProductionRuleToken> productionRuleTokens = RE.GetTokens(); return(productionRuleTokens.Append(SpecialCharToken.TokenSpace, new CardinalityToken(Lower, Upper))); }