const classafConcurrent::SynchronizedList

sys::Obj
  afConcurrent::SynchronizedList

A List that provides fast reads and synchronised writes between threads, ensuring data integrity.

The list is stored in an AtomicRef through which all reads are made.

All write operations ( get, remove & clear ) are made via synchronized blocks ensuring no data is lost during race conditions. Writing makes a rw copy of the map and is thus a more expensive operation.

All values held in the list must be immutable.

add

Source

@Operator
This add(Obj? item)

Add the specified item to the end of the list. Return this.

clear

Source

This clear()

Remove all key/value pairs from the map. Return this.

contains

Source

Bool contains(Obj? item)

Returns true if this list contains the specified item.

each

Source

Void each(|Obj?,Int c)

Call the specified function for every item in the list.

first

Source

Obj? first()

Return the item at index 0, or if empty return null.

get

Source

@Operator
Obj? get(Int index)

Returns the item at the specified index. A negative index may be used to access an index from the end of the list.

insert

Source

This insert(Int index, Obj? item)

Insert the item at the specified index. A negative index may be used to access an index from the end of the list. Size is incremented by 1. Return this. Throw IndexErr if index is out of range. Throw ReadonlyErr if readonly.

isEmpty

Source

Bool isEmpty()

Return true if size() == 0

last

Source

Obj? last()

Return the item at index-1, or if empty return null.

lock

Source

const Synchronized lock

The lock object should you need to synchronize on the List.

make

Source

new make(ActorPool actorPool, |This? f := null)

Creates a SynchronizedMap with the given ActorPool.

peek

Source

Obj? peek()

pop

Source

Obj? pop()

push

Source

This push(Obj? item)

remove

Source

Obj? remove(Obj item)

Removes the specified item from the list, returning the removed item. If the item was not mapped then return null.

removeAt

Source

Obj? removeAt(Int index)

Remove the object at the specified index. A negative index may be used to access an index from the end of the list. Return the item removed.

rw

Source

Obj?[] rw()

Get a read-write, mutable List instance with the same contents.

size

Source

Int size()

Get the number of values in the map.

toStr

Source

virtual override Str toStr()

Returns a string representation the list.

val

Source

Obj?[] val

Gets or sets a read-only copy of the backing map.

valType

Source

const Type valType := sys::Obj?#

Used to parameterize the backing list.

SynchronizedList(actorPool) { it.valType = Str# }