Another small change to MsgThread API.

Threads will now reliably get a call to DoFinish() no matter how the
thread terminates. This will always be called from within the thread,
whereas the destructor is called from the main thread after the child
thread has already terminated.

Also removing debugging code.

However, two problems remain with the ASCII writer (seeing them only
on MacOS):

    - the #start/#end timestamps contain only dummy values right now.
      The odd thing is that once I enable strftime() to print actual
      timestamps, I get crashes (even though strftime() is supposed to
      be thread-safe).

    - occassionally, there's still output missing in tests. In those
      cases, the file descriptor apparently goes bad: a write() will
      suddently return EBADF for reasons I don't understand yet.
This commit is contained in:
Robin Sommer 2012-07-22 15:50:12 -07:00
parent 053b307e24
commit 71fc2a1728
6 changed files with 39 additions and 27 deletions

View file

@ -197,10 +197,6 @@ protected:
*/
virtual void Heartbeat();
/** Flags that the child process has finished processing. Called from child.
*/
void Finished();
/** Internal heartbeat processing. Called from child.
*/
void HeartbeatInChild();
@ -217,8 +213,7 @@ protected:
virtual bool OnHeartbeat(double network_time, double current_time) = 0;
/** Triggered for execution in the child thread just before shutting threads down.
* The child thread should finish its operations and then *must*
* call this class' implementation.
* The child thread should finish its operations.
*/
virtual bool OnFinish(double network_time) = 0;
@ -288,6 +283,10 @@ private:
*/
bool MightHaveOut() { return queue_out.MaybeReady(); }
/** Flags that the child process has finished processing. Called from child.
*/
void Finished();
Queue<BasicInputMessage *> queue_in;
Queue<BasicOutputMessage *> queue_out;