private void Save() { while (true) { lock (_queue) { #if DEBUG ParallelUtility.countLocks("_queue"); #endif if (_queue.Count == 0 && !_shutdown) { Monitor.Wait(_queue); } if (_queue.Count > 0) { ISavable item = _queue.Dequeue(); item.Save(); } else if (_shutdown) { break; } } } }
public RandomUniform01(int randseed = 1) { lock (_randomUniform01ResetLock) { #if DEBUG ParallelUtility.countLocks("_randomUniform01ResetLock"); #endif ResetUniform01(randseed); } }
public TModel Seek(int id) { lock (typeof(TModel)) { #if DEBUG ParallelUtility.countLocks("typeof (TModel)"); #endif return(!_index.TryGetValue(id, out long location) ? null : Seek(location)); } }
public void Add(ISavable obj) { lock (_queue) { #if DEBUG ParallelUtility.countLocks("_queue"); #endif _queue.Enqueue(obj); Monitor.Pulse(_queue); } }
public static int randominteger(int N) { int r = 0; lock (rndobject) { #if DEBUG ParallelUtility.countLocks("rndobject"); #endif r = rndobject.Next(N); } return(r); }
public static double randomreal() { double r = 0; lock (rndobject) { #if DEBUG ParallelUtility.countLocks("rndobject"); #endif r = rndobject.NextDouble(); } return(r); }
public IList <TModel> Seek(int parentId, string indexName) { lock (typeof(TModel)) { #if DEBUG ParallelUtility.countLocks("typeof (TModel)"); #endif Dictionary <int, int[]> index = _indexes[indexName]; return(index.TryGetValue(parentId, out int[] elements) ? elements.Select(Seek).ToList() : new List <TModel>()); } }
public double Uniform01() { lock (_randomUniform01Lock) { #if DEBUG ParallelUtility.countLocks("_randomUniform01Lock"); #endif int r = _randseed / 177; int s = _randseed - 177 * r; _randseed = 171 * s - 2 * r; if (_randseed < 0) { _randseed += 30269; } r = _randSy / 176; s = _randSy - 176 * r; _randSy = 172 * s - 35 * r; if (_randSy < 0) { _randSy += 30307; } r = _randSz / 178; s = _randSz - 178 * r; _randSz = 170 * s - 63 * r; if (_randSz < 0) { _randSz += 30323; } double f = _randseed / 30269D + _randSy / 30307D + _randSz / 30323D; f = f - (int)f; return(f); } }
public void Shutdown() { if (_thread == null) { throw new Exception("ThreadQueue already shutdown."); } lock (_queue) { #if DEBUG ParallelUtility.countLocks("_queue"); #endif _shutdown = true; Monitor.Pulse(_queue); } if (_thread != null) { _thread.Join(); } }