Sha256: 77e3b7cd3c6e668570e704d895911c324b9317eb8f1aedd601d4ea13b4bf3cb8

Contents?: true

Size: 544 Bytes

Versions: 3

Compression:

Stored size: 544 Bytes

Contents

# frozen_string_literal: true

module Nonnative
  class Server < Nonnative::Service
    def initialize(service)
      @service = service
      @id = SecureRandom.hex(5)
    end

    def name
      self.class.to_s
    end

    def start
      unless thread
        @thread = Thread.new { perform_start }
        wait_start
      end

      id
    end

    def stop
      if thread
        perform_stop
        thread.terminate
        @thread = nil
        wait_stop
      end

      id
    end

    attr_reader :service, :id, :thread
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
nonnative-1.14.0 lib/nonnative/server.rb
nonnative-1.13.0 lib/nonnative/server.rb
nonnative-1.12.0 lib/nonnative/server.rb