1
// Copyright 2011 Google Inc.
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
7
// http://www.apache.org/licenses/LICENSE-2.0
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
15
#ifndef MOD_SPDY_COMMON_EXECUTOR_H_
16
#define MOD_SPDY_COMMON_EXECUTOR_H_
18
#include "base/basictypes.h"
19
#include "net/spdy/spdy_protocol.h"
21
namespace net_instaweb { class Function; }
25
// An interface for a service that can execute tasks. A thread pool (using
26
// net_instaweb::QueuedWorkerPool or an apr_thread_pool_t) would be one obvious
27
// implementation. In the future we may want to adjust this interface for use
28
// in an event-driven environment (e.g. Nginx).
34
// Add a new task to be run; the executor takes ownership of the task. The
35
// priority argument hints at how important this task is to get done, but the
36
// executor is free to ignore it. If Stop has already been called, the
37
// executor may immediately cancel the task rather than running it.
38
virtual void AddTask(net_instaweb::Function* task,
39
net::SpdyPriority priority) = 0;
41
// Stop the executor. Cancel all tasks that were pushed onto this executor
42
// but that have not yet begun to run. Tasks that were already running will
43
// continue to run, and this function must block until they have completed.
44
// It must be safe to call this method more than once.
45
virtual void Stop() = 0;
48
DISALLOW_COPY_AND_ASSIGN(Executor);
51
} // namespace mod_spdy
53
#endif // MOD_SPDY_COMMON_EXECUTOR_H_