X hits on this document

PDF document

February 10, 2006 - page 232 / 238

889 views

0 shares

0 downloads

0 comments

232 / 238

220

APPENDIX L. OS HANDLER INTERFACE (OS HANDLER.H)

struct os handler s

_

_

{

/*

Allocate

and

free

data,

like

malloc()

and

free().

These

are

only used in the "main" os handler, too, not in the oned registered for domains. */ void *(*mem_alloc)(int size); void (*mem_free)(void *data);

/*

This is called by the user code to register a callback handler

to be called

when data is

descriptor.

I know, it’s

ready to be read kind of wierd, a

on the given file callback to register

a callback, but it’s the best way I could think of to do this.

This call

will

the wait.

The

is

ready

to

be

return an id that can then be used to cancel called code should register that whenever data r e a d f r o m t h e g i v e n f i l e d e s c r i p t o r , d a t a _ r e a d y

s h o u l d b e c a l l e d w i t h t h e g i v e n c b _ d a t a .

If this is NULL, you

may only call the commands ending in "

code will return errors.

events.

Note

that

these

You also calls may

may NOT

_

wait", the event-driven not receive commands or block. */

int

fd,

_ os_data ready_t

data_ready,

void

*cb_data,

i n t ( * a d d _ f d _ t o _ w a i t _ f o r ) ( o s _ h a n d l e r _ t

*handler,

o s _ f d _ d a t a _ f r e e d _ t f r e e d ,

i n t os_hnd_fd_id_t ( * r e m o v e _ f d _ t o _ w a i t _ f o r ) ( o s _ h a n d l e r _ os_hnd_fd_id t

_

**id); *handler, t *id);

/*

Create a timer. the timer, so no

This will allocate all other timer operations

the data required for should fail due to lack

of memory. */ i n t ( * a l l o c _ t i m e r ) ( o s _ h a n d l e r _ t o s _ h n d _ t i m e r _ i d

_

*handler, t **id);

/* Free the memory for the given timer.

If the timer is running,

stop it first. */ i n t ( * f r e e _ t i m e r ) ( o s _ h a n d l e *handler, r _ t o s _ h n d _ t i m e r _ i d _ t * i d ) ; /* This is called to register a callback handler to be called at the given time or after (absolute time, as seen by

gettimeofday).

After the given time has passed, the

"timed_out" will be called identifier in "id" just be

with the given one previously

cb_data.

The

allocated

with

a l l o c _ t i m e r ( ) .

N o t e t h a t t i m e d _ o u t m a y N O T b l o c k . * /

i n t ( * s t a r t _ t i m e r ) ( o s _ h a n d l e r _ t

*handler,

o s _ h n d _ t i m e r _ i d _ t * i d ,

struct timeval

*timeout,

Document info
Document views889
Page views889
Page last viewedSat Dec 10 17:35:11 UTC 2016
Pages238
Paragraphs8090
Words85809

Comments