Classical Storage¶
The Classical Storage object is a component of a Host used to store message objects.
-
class
qunetsim.objects.storage.classical_storage.
ClassicalStorage
¶ Bases:
object
A classical storage for messages.
-
_add_new_host_id
(host_id)¶ Add a new host to the storage.
- Parameters
host_id (str) – The host ID to store.
-
_add_request
(args)¶ Adds a new request to the classical storage. If a new message arrives, it is checked if the request for the qubit is satisfied.
- Parameters
args (list) – [Queue, from_host_id, type, …]
- Returns
ID of the request
- Return type
(int)
-
_check_all_requests
()¶ Checks if any of the pending requests is now fulfilled.
- Returns
If a request is fulfilled, the request is handled and the function returns the message of this request.
-
_remove_request
(req_id)¶ Removes a pending request from the request dict.
- Parameters
req_id (int) – The id of the request to remove.
-
add_msg_to_storage
(message)¶ Adds a message to the storage.
-
empty
()¶ Empty the classical storage.
-
get_all
()¶ Get all Messages as a list.
- Returns
All Messages as a list.
- Return type
(list) messages
-
get_all_from_sender
(sender_id, wait=0)¶ Get all stored messages from a sender. If delete option is set, the returned messages are removed from the storage.
- Parameters
sender_id (str) – The host id of the host.
wait (int) – Default is 0. The maximum blocking time. -1 to block forever.
- Returns
List of messages of the sender. If there are none, an empty list is returned.
-
get_next_from_sender
(sender_id, wait=0)¶ Gets the next, unread, message from the sender. If there is no message yet, it is waited for the waiting time till a message is arrived. If there is still no message, than None is returned.
- Parameters
sender_id (str) – The sender id of the message to get.
wait (int) – Default is 0. The maximum blocking time. -1 to block forever.
- Returns
Message object, if such a message exists, or none.
-
get_with_seq_num_from_sender
(sender_id, seq_num, wait=0)¶ Gets the next, unread, message from the sender. If there is no message yet, it is waited for the waiting time till a message is arrived. If there is still no message, than None is returned.
- Parameters
sender_id (str) – The sender id of the message to get.
wait (int) – Default is 0. The maximum blocking time. -1 to block forever.
- Returns
Message object, if such a message exists, or none.
-
remove_all_ack
(from_sender=None)¶ Removes all ACK messages stored. If from sender is given, only ACKs from this sender are removed.
- Parameters
from_sender (str) – Host id of the sender, whos ACKs should be delted.
-