internal ScheduledJobHandle(TimeBasedTaskScheduler scheduler, Group group, ThreadStart task, long nextDeadlineNanos, long reschedulingDelayNanos) { this._group = group; this.NextDeadlineNanos = nextDeadlineNanos; _handleRelease = new BinaryLatch(); _cancelListeners = new CopyOnWriteArrayList <CancelListener>(); this._task = () => { try { task.run(); // Use compareAndSet to avoid overriding any cancellation state. if (compareAndSet(SUBMITTED, RUNNABLE) && reschedulingDelayNanos > 0) { // We only reschedule if the rescheduling delay is greater than zero. // A rescheduling delay of zero means this is a delayed task. // If the rescheduling delay is greater than zero, then this is a recurring task. this.NextDeadlineNanos += reschedulingDelayNanos; scheduler.EnqueueTask(this); } } catch (Exception e) { _lastException = e; set(FAILED); } }; }
public NodeListGridAdapter(Context context, bool isResponseEnabled) { mContext = context; mInflater = LayoutInflater.from(mContext); mNodeInfoList = new CopyOnWriteArrayList<NodeInfo>(); }
public NodeListAdapter(Context context, IFileCancelListener fileCancelListener) { mContext = context; mInflater = LayoutInflater.from(mContext); mNodeInfoList = new CopyOnWriteArrayList<NodeInfo>(); mFileCancelListener = fileCancelListener; }
public NodeListAdapter(Context context, IFileCancelListener fileCancelListener) { mContext = context; mInflater = LayoutInflater.from(mContext); mNodeInfoList = new CopyOnWriteArrayList <NodeInfo>(); mFileCancelListener = fileCancelListener; }
public void Add2_IndexOutOfBoundsException() { CopyOnWriteArrayList<string> c = new CopyOnWriteArrayList<string>(); c.Add("asdasd"); c.Add("asdasdasd"); c.Insert(100, "qwerty"); }
private static IList <T> CreateListeners <T>(IList <T> existingListeners) { IList <T> result = new CopyOnWriteArrayList <T>(); ((IList <T>)result).AddRange(existingListeners); return(result); }
public void AddAll2_IndexOutOfBoundsException() { CopyOnWriteArrayList<string> c = new CopyOnWriteArrayList<string>(); c.Add("asdasd"); c.Add("asdasdasd"); c.AddAll(100, new List<string>()); }
public static void addDecodingHook(Class c, Transformer t) { _decodeHooks = true; List<Transformer> l = _decodingHooks.get(c); if (l == null) { l = new CopyOnWriteArrayList<Transformer>(); _decodingHooks.put(c, l); } l.add(t); }
static CopyOnWriteArrayList<Object> PopulatedArray(int n) { CopyOnWriteArrayList<Object> a = new CopyOnWriteArrayList<Object>(); Assert.IsTrue(a.IsEmpty()); for (int i = 0; i < n; ++i) { a.Add(i); } Assert.IsFalse(a.IsEmpty()); Assert.AreEqual(n, a.Size()); return a; }
public void TestConstructor3() { Object[] ints = new Object[SIZE]; for (int i = 0; i < SIZE-1; ++i) { ints[i] = i; } CopyOnWriteArrayList<Object> a = new CopyOnWriteArrayList<Object>(Arrays.AsList(ints)); for (int i = 0; i < SIZE; ++i) { Assert.AreEqual(ints[i], a.Get(i)); } }
private void Add(ListenerHandle handle) { IList <ListenerHandle> list = lists.Get(handle.type); if (list == null) { CopyOnWriteArrayList <ListenerHandle> newList; newList = new CopyOnWriteArrayList <ListenerHandle>(); list = lists.PutIfAbsent(handle.type, newList); if (list == null) { list = newList; } } list.AddItem(handle); }
public void TestSubList3IndexOutOfBoundsException() { try { CopyOnWriteArrayList<Object> c = new CopyOnWriteArrayList<Object>(); c.SubList(3,1); ShouldThrow(); } catch(IndexOutOfRangeException) {} }
public void TestListIterator2IndexOutOfBoundsException() { try { CopyOnWriteArrayList<Object> c = new CopyOnWriteArrayList<Object>(); c.Add("adasd"); c.Add("asdasdas"); c.ListIterator(100); ShouldThrow(); } catch(IndexOutOfRangeException) {} }
public void TestSubList2IndexOutOfBoundsException() { try { CopyOnWriteArrayList<Object> c = new CopyOnWriteArrayList<Object>(); c.Add("asdasd"); c.SubList(1,100); ShouldThrow(); } catch(IndexOutOfRangeException) {} }
public void Get1_IndexOutOfBoundsException() { CopyOnWriteArrayList<int> c = new CopyOnWriteArrayList<int>(); Object generatedAux = c[-1]; }
public void AddAll1_IndexOutOfBoundsException() { CopyOnWriteArrayList<string> c = new CopyOnWriteArrayList<string>(); c.AddAll(-1, new List<string>()); }
public void Remove1_IndexOutOfBounds() { CopyOnWriteArrayList<string> c = new CopyOnWriteArrayList<string>(); c.RemoveAt(-1); }
public TransactionConfidence(Transaction transaction) { // Assume a default number of peers for our set. broadcastBy = new CopyOnWriteArrayList<PeerAddress>(); transaction = tx; }
public void Add1_IndexOutOfBoundsException() { CopyOnWriteArrayList<string> c = new CopyOnWriteArrayList<string>(); c.Insert(-1, "qwerty"); }
public void TestConstructor() { CopyOnWriteArrayList<Object> a = new CopyOnWriteArrayList<Object>(); Assert.IsTrue(a.IsEmpty()); }
public void TestIsEmpty() { CopyOnWriteArrayList<Object> empty = new CopyOnWriteArrayList<Object>(); CopyOnWriteArrayList<Object> full = PopulatedArray(SIZE); Assert.IsTrue(empty.IsEmpty()); Assert.IsFalse(full.IsEmpty()); }
public void Set1_IndexOutOfBoundsException() { CopyOnWriteArrayList<string> c = new CopyOnWriteArrayList<string>(); c[-1] = "qwerty"; }
public NodeListGridAdapter(Context context, bool isResponseEnabled) { mContext = context; mInflater = LayoutInflater.from(mContext); mNodeInfoList = new CopyOnWriteArrayList <NodeInfo>(); }
public void Set2() { CopyOnWriteArrayList<string> c = new CopyOnWriteArrayList<string>(); c.Add("asdasd"); c.Add("asdad"); c[100] = "qwerty"; }
public void Size() { CopyOnWriteArrayList<int> empty = new CopyOnWriteArrayList<int>(); CopyOnWriteArrayList<int> full = populatedArray(DEFAULT_COLLECTION_SIZE); Assert.AreEqual(DEFAULT_COLLECTION_SIZE, full.Count); Assert.AreEqual(0, empty.Count); }
public void Remove2_IndexOutOfBounds() { CopyOnWriteArrayList<string> c = new CopyOnWriteArrayList<string>(); c.Add("asdasd"); c.Add("adasdasd"); c.RemoveAt(100); }
public void TestSet2() { try { CopyOnWriteArrayList<Object> c = new CopyOnWriteArrayList<Object>(); c.Add("asdasd"); c.Add("asdad"); c.Set(100, "qwerty"); ShouldThrow(); } catch(IndexOutOfRangeException) {} }
public Schema createSchema(SessionMetaData sessionMetaData) { SchemaImpl schemaImpl; try { // activate injection process Type schemaClass = typeof(SchemaImpl); schemaImpl = (SchemaImpl)dependencyInjectorFactory.CreateInstance(schemaClass, sessionMetaData, dbProperties, this); FieldInfo property = schemaClass.GetField("core", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public); Core core = (Core)property.GetValue(schemaImpl); // update schemaMap List<Schema> schemas = null; schemaMap.TryGetValue(sessionMetaData.getSchemaId(), out schemas); if (schemas == null) { schemas = new CopyOnWriteArrayList<Schema>(); schemaMap[sessionMetaData.getSchemaId()] = schemas; } schemas.Add(schemaImpl); // update coresMap List<Core> cores = null; coreMap.TryGetValue(sessionMetaData.getSchemaId(), out cores); if (cores == null) { cores = new CopyOnWriteArrayList<Core>(); coreMap[sessionMetaData.getSchemaId()] = cores; } cores.Add(core); } catch (Exception e) { throw new PlanckDBException(CommandStatus.unsupported, "unsupported state the should not reach to this point of the code" + e.Message); } return schemaImpl; }
public void TestAdd1IndexOutOfBoundsException() { try { CopyOnWriteArrayList<Object> c = new CopyOnWriteArrayList<Object>(); c.Add(-1,"qwerty"); ShouldThrow(); } catch(IndexOutOfRangeException) {} }
public void IsEmpty() { CopyOnWriteArrayList<int> empty = new CopyOnWriteArrayList<int>(); CopyOnWriteArrayList<int> full = populatedArray(DEFAULT_COLLECTION_SIZE); Assert.IsTrue(empty.IsEmpty); Assert.IsFalse(full.IsEmpty); }
public void TestRemove2IndexOutOfBounds() { try { CopyOnWriteArrayList<Object> c = new CopyOnWriteArrayList<Object>(); c.Add("asdasd"); c.Add("adasdasd"); c.Remove(100); ShouldThrow(); } catch(IndexOutOfRangeException) {} }
public void Get2_IndexOutOfBoundsException() { CopyOnWriteArrayList<string> c = new CopyOnWriteArrayList<string>(); c.Add("asdasd"); c.Add("asdad"); Object generatedAux = c[100]; }
public void TestAddAll2IndexOutOfBoundsException() { try { CopyOnWriteArrayList<Object> c = new CopyOnWriteArrayList<Object>(); c.Add("asdasd"); c.Add("asdasdasd"); c.AddAll(100, new ArrayList<Object>()); ShouldThrow(); } catch(IndexOutOfRangeException) {} }
internal virtual int FindCachedFunction(Context cx, object[] args) { if (methods.Length > 1) { if (overloadCache != null) { foreach (ResolvedOverload ovl in overloadCache) { if (ovl.Matches(args)) { return ovl.index; } } } else { overloadCache = new CopyOnWriteArrayList<ResolvedOverload>(); } int index = FindFunction(cx, methods, args); // As a sanity measure, don't let the lookup cache grow longer // than twice the number of overloaded methods if (overloadCache.Count < methods.Length * 2) { lock (overloadCache) { ResolvedOverload ovl = new ResolvedOverload(args, index); if (!overloadCache.Contains(ovl)) { overloadCache.Add(0, ovl); } } } return index; } return FindFunction(cx, methods, args); }
internal static CopyOnWriteArrayList<int> populatedArray(int n) { CopyOnWriteArrayList<int> a = new CopyOnWriteArrayList<int>(); Assert.IsTrue(a.IsEmpty); for(int i = 0; i < n; ++i) { a.Add(i); } Assert.IsFalse(a.IsEmpty); Assert.AreEqual(n, a.Count); return a; }
public void TestSize() { CopyOnWriteArrayList<Object> empty = new CopyOnWriteArrayList<Object>(); CopyOnWriteArrayList<Object> full = PopulatedArray(SIZE); Assert.AreEqual(SIZE, full.Size()); Assert.AreEqual(0, empty.Size()); }
public TransactionConfidence(Transaction transaction) { // Assume a default number of peers for our set. broadcastBy = new CopyOnWriteArrayList <PeerAddress>(); transaction = tx; }