Merge pull request #1259 from dqminh/epoll-io

Use Epoll to perform I/O in linux
This commit is contained in:
Stephen Day
2017-07-31 13:47:41 -07:00
committed by GitHub
10 changed files with 210 additions and 22 deletions

View File

@@ -42,10 +42,20 @@ func NewService(path, namespace string, client publisher) (*Service, error) {
namespace: namespace,
context: context,
}
if err := s.initPlatform(); err != nil {
return nil, errors.Wrap(err, "failed to initialized platform behavior")
}
go s.forward(client)
return s, nil
}
// platform handles platform-specific behavior that may differs across
// platform implementations
type platform interface {
copyConsole(ctx context.Context, console console.Console, stdin, stdout, stderr string, wg, cwg *sync.WaitGroup) (console.Console, error)
shutdownConsole(ctx context.Context, console console.Console) error
}
type Service struct {
initProcess *initProcess
path string
@@ -58,10 +68,12 @@ type Service struct {
deferredEvent interface{}
namespace string
context context.Context
platform platform
}
func (s *Service) Create(ctx context.Context, r *shimapi.CreateTaskRequest) (*shimapi.CreateTaskResponse, error) {
process, err := newInitProcess(ctx, s.path, s.namespace, r)
process, err := newInitProcess(ctx, s.platform, s.path, s.namespace, r)
if err != nil {
return nil, errdefs.ToGRPC(err)
}