You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I expect that when the Left branch of the fold is taken, the return value will be of type Option[NestingLevel]. Instead, with high-frequency in the application I am running, I get an exception whose stack trace bottoms out as follows:
Thomas Dickerson (thomas.dickerson) said:
It appears that modifying _.values.headOption to _.readOnlySnapshot.values.headOption in my code fixes the problem, but it seems like highly unexpected behavior that the semantics of these differ (i.e. every iterator returned by functions on a TrieMap should be over a readOnlySnapshot, since this is the core feature advertised in the documention: {quote}It supports O(1), atomic, lock-free snapshots which are used to implement linearizable lock-free size, iterator and clear operations{quote})
Is insufficient to make .values.headOption work with a single version of the datastructure, as we end up calling TrieMap#iterator more than once within that operation.
An override like:
overridedefvaluesIterator:Iterator[V] = {
if (nonReadOnly) readOnlySnapshot().valuesIterator
elsesuper.valuesIterator
}
overridedefkeysIterator:Iterator[K] = {
if (nonReadOnly) readOnlySnapshot().keysIterator
elsesuper.keysIterator
}
@axel22 said (edited on Feb 9, 2017 4:14:26 PM UTC):
I though that if (v1.size == 0) None else Some(v1.iterator.next()) is where the race condition comes from, no? I mean, both size and iterator here result in calling the iterator separately.
Seems like you would have to create the snapshot in the new AbstractIterable ... only once, and use that for the iterator.
I have the following code (where
ownerRef
is of typeAtomicReference[Either[TrieMap[Thread, NestingLevel], (Thread, NestingLevel)]]
):I expect that when the
Left
branch of thefold
is taken, the return value will be of typeOption[NestingLevel]
. Instead, with high-frequency in the application I am running, I get an exception whose stack trace bottoms out as follows:The exception originates in the line of code reproduced above.
The text was updated successfully, but these errors were encountered: