source: geniuswebcore/geniusweb/deadline/DeadlineRounds.py@ 65

Last change on this file since 65 was 59, checked in by Wouter Pasman, 3 years ago

#44 manual commit of first public release, because this will cause the dist directory to move

File size: 1.1 KB
Line 
1from geniusweb.deadline.DeadlineTime import DeadlineTime
2
3class DeadlineRounds (DeadlineTime):
4 '''
5 The number of rounds that a session will be allowed to run. This extends
6 DeadlineTime because a rounds deadline is an ADDITIONAL deadline on top of a
7 normal time deadline. It is not hard defined what a round is, this is up to
8 the protocol.
9 '''
10
11 def __init__(self, rounds:int, durationms:int):
12 '''
13 @param rounds the max number of rounds for the session
14 @param durationms the maximum time in milliseconds the session is allowed
15 to run.
16 '''
17 super().__init__(durationms)
18 if rounds <= 0:
19 raise ValueError("deadline must have at least 1 round")
20 self._rounds = rounds;
21
22 def getRounds(self) ->int:
23 return self._rounds;
24
25 def __hash__(self):
26 prime = 31
27 result = super().__hash__()
28 result = prime * result + hash(self._rounds)
29 return result
30
31 def __eq__(self, other):
32 return isinstance(other, self.__class__) and \
33 super().__eq__(other) and self._rounds == other._rounds
34
35
36 def __repr__(self)->str:
37 return "DeadlineRounds[" + str(self._rounds) + "," + str(self._durationms) + "]";
38
Note: See TracBrowser for help on using the repository browser.