Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
net_instaweb::ControllerProcess Class Referenceabstract

#include "controller_process.h"

Inheritance diagram for net_instaweb::ControllerProcess:
net_instaweb::CentralControllerRpcServer

Public Member Functions

virtual int Setup ()
 
virtual int Run ()=0
 
virtual void Stop ()=0
 

Detailed Description

Abstract class for delegating work to ControllerManager. All of the following is performed in the child process. If the child dies with a non-zero exit status, the babysitter will restart it.

The ControllerManager will first invoke Setup(). If that returns non-zero, the forked process will immediately exit using that return code. Otherwise, the ControllerManager starts a thread monitoring for parent death and invokes Run(). This means Run() and Stop() may be invoked in any order and will be invoked from different threads. The child will exit with the return value of Run() unless Stop() is called (see below).

Note that in the process from which ForkControllerProcess is invoked, this object will be created and then destroyed without any of the methods being invoked.

Member Function Documentation

virtual int net_instaweb::ControllerProcess::Run ( )
pure virtual

Perform your work and return the exit status. Invoked only if Setup() returns 0. Stop() may be called before Run(), in which case Run() should return immediately.

The babysitter respawns the child whenever it dies for any reason other than exit(0). Thus, if the child is dying because it was asked to by the parent process (ie: Stop() was called) the return value of Run() is ignored and an exit status of 0 will be used.

Implemented in net_instaweb::CentralControllerRpcServer.

virtual int net_instaweb::ControllerProcess::Setup ( )
inlinevirtual

Perform any required setup actions. We don't respond to the death of the Apache/Nginx process that spawned us until Setup() returns, so should not spin waiting for a resource. Returns exit status.

Reimplemented in net_instaweb::CentralControllerRpcServer.

virtual void net_instaweb::ControllerProcess::Stop ( )
pure virtual

Notify the Run() thread to stop. Called from a different thread so must be thread safe. May be called before, during or after Run(), possibly multiple times.

Implemented in net_instaweb::CentralControllerRpcServer.


The documentation for this class was generated from the following file: