zoukankan      html  css  js  c++  java
  • lua 写逻辑打印log时,打印到一半后停止不再打印,程序停止

    问题描述:ubuntu下用lua开发游戏电子邮件模块,自己测试时向用户推送100封,而用户最多只能有50封。这是调用sysdelete删除一些邮件。当打印log时,打印到一半后程序中途停止。将打印log的代码删除后又恢复正常。

    目前估计是缓存满了。待解决。。删除邮件代码如下:

    function _M:sysdelemail()
      local readrewarded = {}
      local readunrewarded = {}
      local unread = {}

      for k , v in pairs( self.__data ) do
        if 1 == v.isread then
          if 1 == v.isreward then
            table.insert( readrewarded , v.csv_id )
          else
            table.insert( readunrewarded , v.csv_id )
          end
        else
          local tmp = {}
          tmp.csv_id = v.csv_id
          tmp.acctime = v.acctime
          table.insert( unread , tmp )
        end
      end
    --delete read and getrewarded first

      for _ , v in ipairs( readrewarded ) do
        local tmp = self.__data[ tostring( v ) ]
        tmp.isdel = 1
        tmp:__update_db( { "isdel" } )
        self.__data[ tostring( v ) ] = nil
        self.__count = self.__count - 1
      end

      if self.__count <= self.__MAXEMAILNUM then
        return
      end
    -- if still more than MAXEMAILNUMM then delete read , unrewarded
      for _ , v in ipairs( readunrewarded ) do
        local tmp = self.__data[ tostring( v ) ]
        tmp.isdel = 1
        tmp:__update_db( { "isdel" } )
        self.__data[ tostring( v ) ] = nil
        self.__count = self.__count - 1
      end

      if self.__count <= self.__MAXEMAILNUM then
        return
      end
    -- last delete the earlist unread emails
      table.sort( unread , function ( ta , tb ) return ta.acctime < tb.acctime end )

      --[[ 如果在此打印排序后的邮件列表变回出现描述的问题打印到一半结束,去掉后却正常

        for k , v in ipairs( unread ) do

          print( k , v )

        end

      --]]

      local diff = self.__count - self.__MAXEMAILNUM
      print( "sizeof diff is ****************************************" , diff , #unread )
      local tmp = {}
      for i = 1 , diff do
        tmp = self.__data[ tostring( unread[ i ].csv_id ) ]
        assert( tmp )
        tmp.isdel = 1
        tmp:__update_db( { "isdel" } )
        self.__data[ tostring( unread[ i ].csv_id ) ] = nil

        self.__count = self.__count - 1
      end
      print( "sizeof unread is ****************************************" , self.__count )
    end

      

      昨天以为是缓存区满了,但今天又测试的一下,输出更多的log,没有出现昨天的问题。纠结中,现在用的是 skynet 框架 ,仍在学习中。感觉这会是个定时炸弹,不知哪天爆了。希望用skynet并pengdao过类似问题的同学不吝赐教。。 

  • 相关阅读:
    [ACM] hdu 1671 Phone List (特里)
    Android 记录的(MediaRecorder)而播放(MediaPlayer)
    菜鸟进阶Android Touch事件传递(四)
    九度oj题目&amp;吉大考研11年机试题全解
    怎样取消shutdown关机命令?-shutdown命令的使用解析
    怎样下载并编译Android4.0内核源代码goldfish(图文)
    三角函数图像
    HTML里面Textarea换行总结
    java中使用队列:java.util.Queue
    ContentProvider简单介绍
  • 原文地址:https://www.cnblogs.com/newbeeyu/p/5252927.html
Copyright © 2011-2022 走看看