template <typename ObjType, typename LockType, typename ListType, typename ListIteratorType>

class VmoCursor

Defined at line 160 of file ../../zircon/kernel/vm/include/vm/vm_object.h

Cursor to allow for walking global vmo lists without needing to hold the lock protecting them all

the time. This can be required to enforce order of acquisition with another lock (as in the case

of |discardable_reclaim_candidates_|), or it can be desirable for performance reasons (as in the

case of |all_vmos_|).

In practice at most one cursor is expected to exist, but as the cursor list is global the

overhead of being generic to support multiple cursors is negligible.

|ObjType| is the type of object being tracked in the list (VmObject, VmCowPages etc).

|LockType| is the singleton global lock used to protect the list.

|ListType| is the type of the global vmo list.

|ListIteratorType| is the iterator for |ListType|.

Public Methods

void VmoCursor<ObjType, LockType, ListType, ListIteratorType> ()

Defined at line 163 of file ../../zircon/kernel/vm/include/vm/vm_object.h

void VmoCursor<ObjType, LockType, ListType, ListIteratorType> (LockType * lock, ListType & vmos, CursorsList & cursors)

Constructor takes as arguments the global lock, the global vmo list, and the global list of

cursors to add the newly created cursor to. Should be called while holding the global |lock|.

Defined at line 170 of file ../../zircon/kernel/vm/include/vm/vm_object.h

void ~VmoCursor<ObjType, LockType, ListType, ListIteratorType> ()

Destructor removes this cursor from the global list of all cursors.

Defined at line 184 of file ../../zircon/kernel/vm/include/vm/vm_object.h

ObjType * Next ()

Advance the cursor and return the next element or nullptr if at the end of the list.

Once |Next| has returned nullptr, all subsequent calls will return nullptr.

The caller must hold the global |lock_|.

Defined at line 191 of file ../../zircon/kernel/vm/include/vm/vm_object.h

void AdvanceIf (const ObjType * h)

If the next element is |h|, advance the cursor past it.

The caller must hold the global |lock_|.

Defined at line 204 of file ../../zircon/kernel/vm/include/vm/vm_object.h

void AdvanceCursors (CursorsList & cursors_list, const ObjType * h)

Advances all the cursors in |cursors_list|, calling |AdvanceIf(h)| on each cursor.

The caller must hold the global lock protecting the |cursors_list|.

Defined at line 215 of file ../../zircon/kernel/vm/include/vm/vm_object.h

LockType & lock_ref ()

Defined at line 222 of file ../../zircon/kernel/vm/include/vm/vm_object.h