Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-3083

C++ Consolidate server processing loops in TSimpleServer, TThreadedServer, TThreadPoolServer

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.8, 0.9, 0.9.1, 0.9.2
    • Fix Version/s: 0.9.3
    • Component/s: C++ - Library
    • Labels:
      None

      Description

      Currently the simple and threaded servers all share a very similar serve() workflow. This improvement story is to consolidate them and extract out the specific differences to limit code duplication.

      1. Add TServerFramework that implements serve() and stop() for TServer, but is abstract.

      2. Add virtual methods onClientConnected, onClientDisconnected to TServerFramework and require subclasses to implement them.

      3. TSimpleServer onClientConnected calls TConnectedClient().run() in the serve() thread, thus blocking the server thread until the client disconnects.

      4. TThreadedServer::serve() calls TServerFramework::serve() and then waits for the notification that all clients are gone. ::onClientConnected adds a TConnectedClient to the task set and starts a thread for it. ::onClientDisconnected removes the client from the task set.

      5. TThreadPoolServer would have similar changes.

      The resulting classes will be much smaller, and the specific differences between the servers will be more obvious. Further, the server processing loop which is common to all three will be in one place. This improves the predictability of thrift and helps improve maintainability.

        Attachments

        1. THRIFT-3083-server-files.tar
          150 kB
          James E. King III
        2. THRIFT-3083.patch
          61 kB
          James E. King III

          Issue Links

            Activity

              People

              • Assignee:
                jking3 James E. King III
                Reporter:
                jking3 James E. King III
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: