This is Unofficial EPICS BASE Doxygen Site
fdmgr.cpp File Reference
#include <stddef.h>
#include "locationException.h"
#include "epicsAssert.h"
#include "fdManager.h"
#include "fdmgr.h"
+ Include dependency graph for fdmgr.cpp:

Go to the source code of this file.

Classes

class  fdRegForOldFdmgr
 
class  fdRegForOldFdmgr::noFunctionSpecified
 
class  fdRegForOldFdmgr::doubleDelete
 
class  timerForOldFdmgr
 
class  timerForOldFdmgr::noFunctionSpecified
 
class  timerForOldFdmgr::doubleDelete
 
class  oldFdmgr
 

Functions

LIBCOM_API fdctx *epicsStdCall fdmgr_init (void)
 
LIBCOM_API fdmgrAlarmId epicsStdCall fdmgr_add_timeout (fdctx *pfdctx, struct timeval *ptimeout, pCallBackFDMgr pFunc, void *pParam)
 
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 *pParam)
 
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_delete (fdctx *pfdctx)
 
LIBCOM_API int epicsStdCall fdmgr_clear_fd (fdctx *pfdctx, SOCKET fd)
 
LIBCOM_API int epicsStdCall fdmgr_add_fd (fdctx *pfdctx, SOCKET fd, void(*pfunc)(void *pParam), void *param)
 

Variables

const unsigned mSecPerSec = 1000u
 
const unsigned uSecPerSec = 1000u * mSecPerSec
 

Function Documentation

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

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,
void(*)(void *pParam)  pfunc,
void *  param 
)

Definition at line 331 of file fdmgr.cpp.

333 {
334  return fdmgr_add_callback (pfdctx, fd, fdi_read, pfunc, param);
335 }
Definition: fdmgr.h:33
LIBCOM_API int epicsStdCall fdmgr_add_callback(fdctx *pfdctx, SOCKET fd, enum fdi_type fdi, pCallBackFDMgr pFunc, void *pParam)
Definition: fdmgr.cpp:229
LIBCOM_API fdmgrAlarmId epicsStdCall fdmgr_add_timeout ( fdctx pfdctx,
struct timeval ptimeout,
pCallBackFDMgr  pFunc,
void *  pParam 
)

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

Variable Documentation

const unsigned mSecPerSec = 1000u

Definition at line 32 of file fdmgr.cpp.

const unsigned uSecPerSec = 1000u * mSecPerSec

Definition at line 33 of file fdmgr.cpp.