EPICS Base 7.0.8.0
Loading...
Searching...
No Matches
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 "dbCoreAPI.h"
22
23#ifdef __cplusplus
24extern "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
41typedef 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)
50#endif
51
52typedef void (*CALLBACKFUNC)(struct callbackPvt*);
53
54typedef 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
72DBCORE_API void callbackInit(void);
73DBCORE_API void callbackStop(void);
74DBCORE_API void callbackCleanup(void);
75DBCORE_API int callbackRequest(epicsCallback *pCallback);
76DBCORE_API void callbackSetProcess(
77 epicsCallback *pcallback, int Priority, void *pRec);
78DBCORE_API int callbackRequestProcessCallback(
79 epicsCallback *pCallback,int Priority, void *pRec);
80DBCORE_API void callbackRequestDelayed(
81 epicsCallback *pCallback,double seconds);
82DBCORE_API void callbackCancelDelayed(epicsCallback *pcallback);
83DBCORE_API void callbackRequestProcessCallbackDelayed(
84 epicsCallback *pCallback, int Priority, void *pRec, double seconds);
85DBCORE_API int callbackSetQueueSize(int size);
86DBCORE_API int callbackQueueStatus(const int reset, callbackQueueStats *result);
87DBCORE_API void callbackQueueShow(const int reset);
88DBCORE_API int callbackParallelThreads(int count, const char *prio);
89
90#ifdef __cplusplus
91}
92#endif
93
94#endif /*INCcallbackh*/