EPICS Base  7.0.5.1
callback.h
1 /*************************************************************************\
2 * Copyright (c) 2007 UChicago Argonne LLC, as Operator of Argonne
3 * National Laboratory.
4 * Copyright (c) 2002 The Regents of the University of California, as
5 * Operator of Los Alamos National Laboratory.
6 * Copyright (c) 2013 ITER Organization.
7 * SPDX-License-Identifier: EPICS
8 * EPICS BASE is distributed subject to a Software License Agreement found
9 * in file LICENSE that is included with this distribution.
10 \*************************************************************************/
11 
12 /* includes for general purpose callback tasks */
13 /*
14  * Original Author: Marty Kraimer
15  * Date: 07-18-91
16 */
17 
18 #ifndef INCcallbackh
19 #define INCcallbackh 1
20 
21 #include "shareLib.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /*
28  * WINDOWS also has a "CALLBACK" type def
29  */
30 #if defined(_WIN32) && !defined(EPICS_NO_CALLBACK)
31 # ifdef CALLBACK
32 # undef CALLBACK
33 # endif /*CALLBACK*/
34 #endif /*_WIN32*/
35 
36 #define NUM_CALLBACK_PRIORITIES 3
37 #define priorityLow 0
38 #define priorityMedium 1
39 #define priorityHigh 2
40 
41 typedef struct callbackPvt {
42  void (*callback)(struct callbackPvt*);
43  int priority;
44  void *user; /*for use by callback user*/
45  void *timer; /*for use by callback itself*/
47 
48 #if !defined(EPICS_NO_CALLBACK)
49 typedef epicsCallback CALLBACK;
50 #endif
51 
52 typedef void (*CALLBACKFUNC)(struct callbackPvt*);
53 
54 typedef struct callbackQueueStats {
55  int size;
56  int numUsed[NUM_CALLBACK_PRIORITIES];
57  int maxUsed[NUM_CALLBACK_PRIORITIES];
58  int numOverflow[NUM_CALLBACK_PRIORITIES];
60 
61 #define callbackSetCallback(PFUN, PCALLBACK) \
62  ( (PCALLBACK)->callback = (PFUN) )
63 #define callbackSetPriority(PRIORITY, PCALLBACK) \
64  ( (PCALLBACK)->priority = (PRIORITY) )
65 #define callbackGetPriority(PRIORITY, PCALLBACK) \
66  ( (PRIORITY) = (PCALLBACK)->priority )
67 #define callbackSetUser(USER, PCALLBACK) \
68  ( (PCALLBACK)->user = (void *) (USER) )
69 #define callbackGetUser(USER, PCALLBACK) \
70  ( (USER) = (PCALLBACK)->user )
71 
72 epicsShareFunc void callbackInit(void);
73 epicsShareFunc void callbackStop(void);
74 epicsShareFunc void callbackCleanup(void);
75 epicsShareFunc int callbackRequest(epicsCallback *pCallback);
76 epicsShareFunc void callbackSetProcess(
77  epicsCallback *pcallback, int Priority, void *pRec);
78 epicsShareFunc int callbackRequestProcessCallback(
79  epicsCallback *pCallback,int Priority, void *pRec);
80 epicsShareFunc void callbackRequestDelayed(
81  epicsCallback *pCallback,double seconds);
82 epicsShareFunc void callbackCancelDelayed(epicsCallback *pcallback);
83 epicsShareFunc void callbackRequestProcessCallbackDelayed(
84  epicsCallback *pCallback, int Priority, void *pRec, double seconds);
85 epicsShareFunc int callbackSetQueueSize(int size);
86 epicsShareFunc int callbackQueueStatus(const int reset, callbackQueueStats *result);
87 epicsShareFunc void callbackQueueShow(const int reset);
88 epicsShareFunc int callbackParallelThreads(int count, const char *prio);
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 
94 #endif /*INCcallbackh*/
Mark external symbols and entry points for shared libraries.