Add homework 01 guarantees assignment
This commit is contained in:
@@ -0,0 +1,177 @@
|
||||
from anysystem import Context, Message, Process
|
||||
|
||||
|
||||
# AT MOST ONCE ---------------------------------------------------------------------------------------------------------
|
||||
|
||||
class AtMostOnceSender(Process):
|
||||
def __init__(self, proc_id: str, receiver_id: str):
|
||||
self._id = proc_id
|
||||
self._receiver = receiver_id
|
||||
|
||||
def on_local_message(self, msg: Message, ctx: Context):
|
||||
# receive message for delivery from local user
|
||||
pass
|
||||
|
||||
def on_start(self, ctx: Context):
|
||||
pass
|
||||
|
||||
def on_message(self, msg: Message, sender: str, ctx: Context):
|
||||
# process messages from receiver here
|
||||
pass
|
||||
|
||||
def on_timer(self, timer_name: str, ctx: Context):
|
||||
# process fired timers here
|
||||
pass
|
||||
|
||||
|
||||
class AtMostOnceReceiver(Process):
|
||||
def __init__(self, proc_id: str):
|
||||
self._id = proc_id
|
||||
|
||||
def on_local_message(self, msg: Message, ctx: Context):
|
||||
# not used in this task
|
||||
pass
|
||||
|
||||
def on_start(self, ctx: Context):
|
||||
pass
|
||||
|
||||
def on_message(self, msg: Message, sender: str, ctx: Context):
|
||||
# process messages from receiver
|
||||
# deliver message to local user with ctx.send_local()
|
||||
pass
|
||||
|
||||
def on_timer(self, timer_name: str, ctx: Context):
|
||||
# process fired timers here
|
||||
pass
|
||||
|
||||
|
||||
# AT LEAST ONCE --------------------------------------------------------------------------------------------------------
|
||||
|
||||
class AtLeastOnceSender(Process):
|
||||
def __init__(self, proc_id: str, receiver_id: str):
|
||||
self._id = proc_id
|
||||
self._receiver = receiver_id
|
||||
|
||||
def on_local_message(self, msg: Message, ctx: Context):
|
||||
# receive message for delivery from local user
|
||||
pass
|
||||
|
||||
def on_start(self, ctx: Context):
|
||||
pass
|
||||
|
||||
def on_message(self, msg: Message, sender: str, ctx: Context):
|
||||
# process messages from receiver here
|
||||
pass
|
||||
|
||||
def on_timer(self, timer_name: str, ctx: Context):
|
||||
# process fired timers here
|
||||
pass
|
||||
|
||||
|
||||
class AtLeastOnceReceiver(Process):
|
||||
def __init__(self, proc_id: str):
|
||||
self._id = proc_id
|
||||
|
||||
def on_local_message(self, msg: Message, ctx: Context):
|
||||
# not used in this task
|
||||
pass
|
||||
|
||||
def on_start(self, ctx: Context):
|
||||
pass
|
||||
|
||||
def on_message(self, msg: Message, sender: str, ctx: Context):
|
||||
# process messages from receiver
|
||||
# deliver message to local user with ctx.send_local()
|
||||
pass
|
||||
|
||||
def on_timer(self, timer_name: str, ctx: Context):
|
||||
# process fired timers here
|
||||
pass
|
||||
|
||||
|
||||
# EXACTLY ONCE ---------------------------------------------------------------------------------------------------------
|
||||
|
||||
class ExactlyOnceSender(Process):
|
||||
def __init__(self, proc_id: str, receiver_id: str):
|
||||
self._id = proc_id
|
||||
self._receiver = receiver_id
|
||||
|
||||
def on_local_message(self, msg: Message, ctx: Context):
|
||||
# receive message for delivery from local user
|
||||
pass
|
||||
|
||||
def on_start(self, ctx: Context):
|
||||
pass
|
||||
|
||||
def on_message(self, msg: Message, sender: str, ctx: Context):
|
||||
# process messages from receiver here
|
||||
pass
|
||||
|
||||
def on_timer(self, timer_name: str, ctx: Context):
|
||||
# process fired timers here
|
||||
pass
|
||||
|
||||
|
||||
class ExactlyOnceReceiver(Process):
|
||||
def __init__(self, proc_id: str):
|
||||
self._id = proc_id
|
||||
|
||||
def on_local_message(self, msg: Message, ctx: Context):
|
||||
# not used in this task
|
||||
pass
|
||||
|
||||
def on_start(self, ctx: Context):
|
||||
pass
|
||||
|
||||
def on_message(self, msg: Message, sender: str, ctx: Context):
|
||||
# process messages from receiver
|
||||
# deliver message to local user with ctx.send_local()
|
||||
pass
|
||||
|
||||
def on_timer(self, timer_name: str, ctx: Context):
|
||||
# process fired timers here
|
||||
pass
|
||||
|
||||
|
||||
# EXACTLY ONCE + ORDERED -----------------------------------------------------------------------------------------------
|
||||
|
||||
class ExactlyOnceOrderedSender(Process):
|
||||
def __init__(self, proc_id: str, receiver_id: str):
|
||||
self._id = proc_id
|
||||
self._receiver = receiver_id
|
||||
|
||||
def on_local_message(self, msg: Message, ctx: Context):
|
||||
# receive message for delivery from local user
|
||||
pass
|
||||
|
||||
def on_start(self, ctx: Context):
|
||||
pass
|
||||
|
||||
def on_message(self, msg: Message, sender: str, ctx: Context):
|
||||
# process messages from receiver here
|
||||
pass
|
||||
|
||||
def on_timer(self, timer_name: str, ctx: Context):
|
||||
# process fired timers here
|
||||
pass
|
||||
|
||||
|
||||
class ExactlyOnceOrderedReceiver(Process):
|
||||
def __init__(self, proc_id: str):
|
||||
self._id = proc_id
|
||||
|
||||
def on_local_message(self, msg: Message, ctx: Context):
|
||||
# not used in this task
|
||||
pass
|
||||
|
||||
def on_start(self, ctx: Context):
|
||||
pass
|
||||
|
||||
def on_message(self, msg: Message, sender: str, ctx: Context):
|
||||
# process messages from receiver
|
||||
# deliver message to local user with ctx.send_local()
|
||||
pass
|
||||
|
||||
def on_timer(self, timer_name: str, ctx: Context):
|
||||
# process fired timers here
|
||||
pass
|
||||
Reference in New Issue
Block a user