Memory Timecard

class sequence.network_management.memory_timecard.MemoryTimeCard(memory_index: int)
Class for tracking reservations on a specific memory.

Each quantum memory in a memory array is associated with a memory time card

memory_index

index of memory being tracked (in the memory array).

Type:

int

reservations

list of reservations for the memory.

Type:

list[Reservation]

add(reservation: Reservation) bool

Method to add reservation.

Will use the schedule_reservation() to determine the index to insert reservation.

Parameters:

reservation (Reservation) – reservation to add.

Returns:

whether reservation was inserted successfully.

Return type:

bool

remove(reservation: Reservation) bool

Method to remove a reservation.

Parameters:

reservation (Reservation) – reservation to remove.

Returns:

if a reservation was already on the memory (return True) or not (return False).

Return type:

bool

schedule_reservation(reservation: Reservation) int

Method to add reservation to a memory.

Will return the index at which reservation can be inserted into memory reservation list. If no space is found for reservation, will raise an exception.

Parameters:

reservation (Reservation) – reservation to schedule.

Returns:

index to insert a reservation in the reservation list.

Return type:

int

Raises:

Exception – no valid index to insert reservation.