1 // Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
2 //
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License, version 2.0, as
5 // published by the Free Software Foundation.
6 //
7 // This program is also distributed with certain software (including
8 // but not limited to OpenSSL) that is licensed under separate terms,
9 // as designated in a particular file or component or in included license
10 // documentation. The authors of MySQL hereby grant you an
11 // additional permission to link the program and your derivative works
12 // with the separately licensed software that they have included with
13 // MySQL.
14 //
15 // Without limiting anything contained in the foregoing, this file,
16 // which is part of MySQL Server, is also subject to the
17 // Universal FOSS Exception, version 1.0, a copy of which can be found at
18 // http://oss.oracle.com/licenses/universal-foss-exception.
19 //
20 // This program is distributed in the hope that it will be useful, but
21 // WITHOUT ANY WARRANTY; without even the implied warranty of
22 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 // See the GNU General Public License, version 2.0, for more details.
24 //
25 // You should have received a copy of the GNU General Public License
26 // along with this program; if not, write to the Free Software Foundation, Inc.,
27 // 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 
29 #ifndef COMPONENTS_SERVICES_PSI_IDLE_BITS_H
30 #define COMPONENTS_SERVICES_PSI_IDLE_BITS_H
31 
32 /**
33   @file
34   Performance schema instrumentation interface.
35 
36   @defgroup psi_abi_idle Idle Instrumentation (ABI)
37   @ingroup psi_abi
38   @{
39 */
40 
41 /**
42   Interface for an instrumented idle operation.
43   This is an opaque structure.
44 */
45 struct PSI_idle_locker;
46 typedef struct PSI_idle_locker PSI_idle_locker;
47 
48 /**
49   State data storage for @c start_idle_wait_v1_t.
50   This structure provide temporary storage to an idle locker.
51   The content of this structure is considered opaque,
52   the fields are only hints of what an implementation
53   of the psi interface can use.
54   This memory is provided by the instrumented code for performance reasons.
55   @sa start_idle_wait_v1_t.
56 */
57 struct PSI_idle_locker_state_v1 {
58   /** Internal state. */
59   unsigned int m_flags;
60   /** Current thread. */
61   struct PSI_thread *m_thread;
62   /** Timer start. */
63   unsigned long long m_timer_start;
64   /** Timer function. */
65   unsigned long long (*m_timer)(void);
66   /** Internal data. */
67   void *m_wait;
68 };
69 typedef struct PSI_idle_locker_state_v1 PSI_idle_locker_state_v1;
70 
71 /**
72   Record an idle instrumentation wait start event.
73   @param state data storage for the locker
74   @param src_file the source file name
75   @param src_line the source line number
76   @return an idle locker, or NULL
77 */
78 typedef struct PSI_idle_locker *(*start_idle_wait_v1_t)(
79     struct PSI_idle_locker_state_v1 *state, const char *src_file,
80     unsigned int src_line);
81 
82 /**
83   Record an idle instrumentation wait end event.
84   @param locker a thread locker for the running thread
85 */
86 typedef void (*end_idle_wait_v1_t)(struct PSI_idle_locker *locker);
87 
88 typedef struct PSI_idle_locker_state_v1 PSI_idle_locker_state;
89 
90 /** @} (end of group psi_abi_idle) */
91 
92 #endif /* COMPONENTS_SERVICES_PSI_IDLE_BITS_H */
93