~ps10gel/ubuntu/xenial/trafficserver/6.2.0

« back to all changes in this revision

Viewing changes to iocore/aio/I_AIO.h

  • Committer: Bazaar Package Importer
  • Author(s): Arno Toell
  • Date: 2011-01-13 11:49:18 UTC
  • Revision ID: james.westby@ubuntu.com-20110113114918-vu422h8dknrgkj15
Tags: upstream-2.1.5-unstable
ImportĀ upstreamĀ versionĀ 2.1.5-unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** @file
 
2
 
 
3
  A brief file description
 
4
 
 
5
  @section license License
 
6
 
 
7
  Licensed to the Apache Software Foundation (ASF) under one
 
8
  or more contributor license agreements.  See the NOTICE file
 
9
  distributed with this work for additional information
 
10
  regarding copyright ownership.  The ASF licenses this file
 
11
  to you under the Apache License, Version 2.0 (the
 
12
  "License"); you may not use this file except in compliance
 
13
  with the License.  You may obtain a copy of the License at
 
14
 
 
15
      http://www.apache.org/licenses/LICENSE-2.0
 
16
 
 
17
  Unless required by applicable law or agreed to in writing, software
 
18
  distributed under the License is distributed on an "AS IS" BASIS,
 
19
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
20
  See the License for the specific language governing permissions and
 
21
  limitations under the License.
 
22
 */
 
23
 
 
24
/****************************************************************************
 
25
 
 
26
  Async Disk IO operations.
 
27
 
 
28
 
 
29
 
 
30
 ****************************************************************************/
 
31
#if !defined (_I_AIO_h_)
 
32
#define _I_AIO_h_
 
33
 
 
34
#ifndef TS_INLINE
 
35
#define TS_INLINE
 
36
#endif
 
37
 
 
38
#include "libts.h"
 
39
#include "I_EventSystem.h"
 
40
#include "I_RecProcess.h"
 
41
 
 
42
#define AIO_MODULE_MAJOR_VERSION 1
 
43
#define AIO_MODULE_MINOR_VERSION 0
 
44
#define AIO_MODULE_VERSION       makeModuleVersion(AIO_MODULE_MAJOR_VERSION,\
 
45
                                                   AIO_MODULE_MINOR_VERSION,\
 
46
                                                   PUBLIC_MODULE_HEADER)
 
47
 
 
48
#define AIO_EVENT_DONE           (AIO_EVENT_EVENTS_START+0)
 
49
 
 
50
#define AIO_MODE_AIO             0
 
51
#define AIO_MODE_SYNC            1
 
52
#define AIO_MODE_THREAD          2
 
53
#define AIO_MODE                 AIO_MODE_THREAD
 
54
 
 
55
// AIOCallback::thread special values
 
56
#define AIO_CALLBACK_THREAD_ANY ((EThread*)0) // any regular event thread
 
57
#define AIO_CALLBACK_THREAD_AIO ((EThread*)-1)
 
58
 
 
59
#define AIO_LOWEST_PRIORITY      0
 
60
#define AIO_DEFAULT_PRIORITY     AIO_LOWEST_PRIORITY
 
61
 
 
62
struct AIOCallback: public Continuation
 
63
{
 
64
  // set before calling aio_read/aio_write
 
65
  ink_aiocb_t aiocb;
 
66
  Action action;
 
67
  EThread *thread;
 
68
  AIOCallback *then;
 
69
  // set on return from aio_read/aio_write
 
70
  int aio_result;
 
71
 
 
72
  int ok();
 
73
  AIOCallback() : thread(AIO_CALLBACK_THREAD_ANY), then(0) {
 
74
    aiocb.aio_reqprio = AIO_DEFAULT_PRIORITY;
 
75
  }
 
76
};
 
77
 
 
78
void ink_aio_init(ModuleVersion version);
 
79
int ink_aio_start();
 
80
void ink_aio_set_callback(Continuation * error_callback);
 
81
 
 
82
int ink_aio_read(AIOCallback *op, int fromAPI = 0);   // fromAPI is a boolean to indicate if this is from a API call such as upload proxy feature
 
83
int ink_aio_write(AIOCallback *op, int fromAPI = 0);
 
84
int ink_aio_thread_num_set(int thread_num);
 
85
AIOCallback *new_AIOCallback(void);
 
86
#endif