Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 112 lines (81 sloc) 1.689 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
#ifndef RBX_WINDOWS
#include <sys/select.h>
#endif
#include <vector>

#include "util/thread.hpp"

#include "windows_compat.h"

namespace rubinius {
  class SharedState;

  namespace agent {
    class VariableAccess;
    class Output;
  }

  class Thread;

  class QueryAgent : public thread::Thread {
    SharedState& shared_;
    VM* state_;
    bool running_;
    int port_;
    int server_fd_;
    bool verbose_;
    fd_set fds_;
    int max_fd_;
    bool exit_;

    int control_[2];
    int loopback_[2];

    int a2r_[2];
    int r2a_[2];

    std::vector<int> sockets_;

    agent::VariableAccess* vars_;

    const static int cBackLog = 10;

  public:
    QueryAgent(SharedState& shared, VM* state);

    void set_verbose() {
      verbose_ = true;
    }

    bool running() {
      return running_;
    }

    int port() {
      return port_;
    }

    void add_fd(int fd) {
      FD_SET((int_fd_t)fd, &fds_);
      if(fd > max_fd_) max_fd_ = fd;
    }

    void remove_fd(int fd) {
      FD_CLR((int_fd_t)fd, &fds_);
    }

    int loopback_socket() {
      return loopback_[1];
    }

    int read_control() {
      return control_[0];
    }

    int write_control() {
      return control_[1];
    }

    int a2r_agent() {
      return a2r_[1];
    }

    int a2r_ruby() {
      return a2r_[0];
    }

    int r2a_agent() {
      return r2a_[0];
    }

    int r2a_ruby() {
      return r2a_[1];
    }

    void wakeup();

    bool setup_local();
    bool bind(int port);

    void make_discoverable();

    virtual void perform();
    bool process_commands(int client);

    void on_fork();
    void cleanup();

    static void shutdown(STATE);
    void shutdown_i();
  };
}
Something went wrong with that request. Please try again.