Ejemplo n.º 1
0
    def next_n(self, how_many):
        self.tick = 1
        front = self.games[:int(how_many)]
        self.games = self.games[int(how_many):]

        # Convert internal representation to GameInfo sequence
        ret = map(lambda g: TicTacToe.GameInfo(g[0], g[2]), front)

        if self.games:
            more = 1
        else:
            more = 0

        return (ret, more)
Ejemplo n.º 2
0
    def listGames(self, how_many):
        self.lock.acquire()
        front = self.games[:int(how_many)]
        rest = self.games[int(how_many):]
        self.lock.release()

        # Create list of GameInfo structures to return
        ret = map(lambda g: TicTacToe.GameInfo(g[0], g[2]), front)

        # Create iterator if necessary
        if rest:
            iter = GameIterator_i(self, self.iterator_poa, rest)
            iid = self.iterator_poa.activate_object(iter)
            iobj = self.iterator_poa.id_to_reference(iid)
            self.lock.acquire()
            self.iterators[iid] = iter
            self.lock.release()
        else:
            iobj = None  # Nil object reference

        return (ret, iobj)