This is Unofficial EPICS BASE Doxygen Site
fdmgr.h File Reference
#include "ellLib.h"
#include "bucketLib.h"
#include "osiSock.h"
#include "epicsThread.h"
#include "libComAPI.h"
+ Include dependency graph for fdmgr.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define NEW_FDMGR_ALARMID
 
#define fdmgrNoAlarm   0
 

Typedefs

typedef void fdctx
 
typedef void(* pCallBackFDMgr) (void *)
 
typedef unsigned fdmgrAlarmId
 

Enumerations

enum  fdi_type { fdi_read, fdi_write, fdi_excp }
 
enum  alarm_list_type { alt_invalid, alt_alarm, alt_expired, alt_free }
 

Functions

LIBCOM_API fdctx *epicsStdCall fdmgr_init (void)
 
LIBCOM_API fdmgrAlarmId epicsStdCall fdmgr_add_timeout (fdctx *pfdctx, struct timeval *ptimeout, pCallBackFDMgr pfunc, void *param)
 
LIBCOM_API int epicsStdCall fdmgr_clear_timeout (fdctx *pfdctx, fdmgrAlarmId id)
 
LIBCOM_API int epicsStdCall fdmgr_add_callback (fdctx *pfdctx, SOCKET fd, enum fdi_type fdi, pCallBackFDMgr pfunc, void *param)
 
LIBCOM_API int epicsStdCall fdmgr_clear_callback (fdctx *pfdctx, SOCKET fd, enum fdi_type fdi)
 
LIBCOM_API int epicsStdCall fdmgr_pend_event (fdctx *pfdctx, struct timeval *ptimeout)
 
LIBCOM_API int epicsStdCall fdmgr_clear_fd (fdctx *pfdctx, SOCKET fd)
 
LIBCOM_API int epicsStdCall fdmgr_add_fd (fdctx *pfdctx, SOCKET fd, pCallBackFDMgr pfunc, void *param)
 
LIBCOM_API int epicsStdCall fdmgr_delete (fdctx *pfdctx)
 

Macro Definition Documentation

#define fdmgrNoAlarm   0

Definition at line 76 of file fdmgr.h.

#define NEW_FDMGR_ALARMID

Definition at line 61 of file fdmgr.h.

Typedef Documentation

typedef void fdctx

Definition at line 36 of file fdmgr.h.

typedef unsigned fdmgrAlarmId

Definition at line 60 of file fdmgr.h.

typedef void(* pCallBackFDMgr) (void *)

Definition at line 37 of file fdmgr.h.

Enumeration Type Documentation

Enumerator
alt_invalid 
alt_alarm 
alt_expired 
alt_free 

Definition at line 34 of file fdmgr.h.

enum fdi_type
Enumerator
fdi_read 
fdi_write 
fdi_excp 

Definition at line 33 of file fdmgr.h.

Function Documentation

LIBCOM_API int epicsStdCall fdmgr_add_callback ( fdctx pfdctx,
SOCKET  fd,
enum fdi_type  fdi,
pCallBackFDMgr  pfunc,
void *  param 
)

Definition at line 229 of file fdmgr.cpp.

231 {
232  oldFdmgr *pfdm = static_cast <oldFdmgr *> (pfdctx);
233  fdRegForOldFdmgr *pfdrbc;
234  bool onceOnly = (fdi==fdi_write);
235  unsigned fdiType;
236 
237  if (pfdm==NULL) {
238  return -1;
239  }
240 
241  if (pFunc==NULL) {
242  return -1;
243  }
244 
245  if (fdi<0) {
246  return -1;
247  }
248 
249  fdiType = (unsigned) fdi;
250 
251  if (fdiType>=fdiToFdRegTypeNElements) {
252  return -1;
253  }
254 
255  try {
256  pfdrbc = new fdRegForOldFdmgr (fd, fdiToFdRegType[fdiType], onceOnly, *pfdm, pFunc, pParam);
257  }
258  catch (...)
259  {
260  pfdrbc = NULL;
261  }
262 
263  if (pfdrbc==NULL) {
264  return -1;
265  }
266  else {
267  return 0;
268  }
269 }
#define NULL
Definition: catime.c:38
LIBCOM_API int epicsStdCall fdmgr_add_fd ( fdctx pfdctx,
SOCKET  fd,
pCallBackFDMgr  pfunc,
void *  param 
)
LIBCOM_API fdmgrAlarmId epicsStdCall fdmgr_add_timeout ( fdctx pfdctx,
struct timeval ptimeout,
pCallBackFDMgr  pfunc,
void *  param 
)

Definition at line 171 of file fdmgr.cpp.

173 {
174  double delay = ptimeout->tv_sec + ptimeout->tv_usec / static_cast <const double> (uSecPerSec);
175  oldFdmgr *pfdm = static_cast <oldFdmgr *> (pfdctx);
176  timerForOldFdmgr *pTimer;
177  unsigned id = fdmgrNoAlarm;
178 
179  if (!pfdm) {
180  return fdmgrNoAlarm;
181  }
182 
183  while (true) {
184  try {
185  pTimer = new timerForOldFdmgr
186  (*pfdm, delay, pFunc, pParam);
187  }
188  catch (...)
189  {
190  pTimer = NULL;
191  }
192  if (pTimer) {
193  id = pTimer->getId ();
194  if (id!=fdmgrNoAlarm) {
195  break;
196  }
197  else {
198  delete pTimer;
199  }
200  }
201  else {
202  break;
203  }
204  }
205 
206  return id;
207 }
#define NULL
Definition: catime.c:38
const unsigned uSecPerSec
Definition: fdmgr.cpp:33
#define fdmgrNoAlarm
Definition: fdmgr.h:76
LIBCOM_API int epicsStdCall fdmgr_clear_callback ( fdctx pfdctx,
SOCKET  fd,
enum fdi_type  fdi 
)

Definition at line 271 of file fdmgr.cpp.

273 {
274  oldFdmgr *pfdm = static_cast <oldFdmgr *> (pfdctx);
275  fdReg *pFDR;
276 
277  if (pfdm==NULL) {
278  return -1;
279  }
280 
281  try {
282  pFDR = pfdm->lookUpFD (fd, fdiToFdRegType[fdi]);
283  }
284  catch (...)
285  {
286  pFDR = NULL;
287  }
288 
289  if (pFDR==NULL) {
290  return -1;
291  }
292  else {
293  delete pFDR;
294  return 0;
295  }
296 }
#define NULL
Definition: catime.c:38
LIBCOM_API class fdReg * lookUpFD(const SOCKET fd, const fdRegType type)
Definition: fdManager.cpp:333
LIBCOM_API int epicsStdCall fdmgr_clear_fd ( fdctx pfdctx,
SOCKET  fd 
)

Definition at line 323 of file fdmgr.cpp.

324 {
325  return fdmgr_clear_callback(pfdctx, fd, fdi_read);
326 }
Definition: fdmgr.h:33
LIBCOM_API int epicsStdCall fdmgr_clear_callback(fdctx *pfdctx, SOCKET fd, enum fdi_type fdi)
Definition: fdmgr.cpp:271
LIBCOM_API int epicsStdCall fdmgr_clear_timeout ( fdctx pfdctx,
fdmgrAlarmId  id 
)

Definition at line 209 of file fdmgr.cpp.

210 {
211  oldFdmgr *pfdm = static_cast <oldFdmgr *> (pfdctx);
212  timerForOldFdmgr *pTimer;
213 
214  try {
215  pTimer = pfdm->resTbl.remove (id);
216  }
217  catch (...)
218  {
219  pTimer = NULL;
220  }
221 
222  if (pTimer==NULL) {
223  return -1;
224  }
225  delete pTimer;
226  return 0;
227 }
#define NULL
Definition: catime.c:38
T * remove(const ID &idIn)
Definition: resourceLib.h:297
LIBCOM_API int epicsStdCall fdmgr_delete ( fdctx pfdctx)

Definition at line 313 of file fdmgr.cpp.

314 {
315  oldFdmgr *pfdm = static_cast <oldFdmgr *> (pfdctx);
316  delete pfdm;
317  return 0;
318 }
LIBCOM_API fdctx* epicsStdCall fdmgr_init ( void  )

Definition at line 156 of file fdmgr.cpp.

157 {
158  oldFdmgr *pfdm;
159 
160  try {
161  pfdm = new oldFdmgr();
162  }
163  catch (...)
164  {
165  pfdm = NULL;
166  }
167 
168  return (fdctx *) pfdm;
169 }
void fdctx
Definition: fdmgr.h:36
#define NULL
Definition: catime.c:38
LIBCOM_API int epicsStdCall fdmgr_pend_event ( fdctx pfdctx,
struct timeval ptimeout 
)

Definition at line 298 of file fdmgr.cpp.

299 {
300  oldFdmgr *pfdm = static_cast <oldFdmgr *> (pfdctx);
301  double delay = ptimeout->tv_sec + ptimeout->tv_usec / static_cast <const double> (uSecPerSec);
302 
303  try {
304  pfdm->process (delay);
305  }
306  catch (...) {
307  return -1;
308  }
309 
310  return 0;
311 }
LIBCOM_API void process(double delay)
Definition: fdManager.cpp:80
const unsigned uSecPerSec
Definition: fdmgr.cpp:33