david/ipxe
Archived
1
0
This repository has been archived on 2020-12-06. You can view files and clone it, but cannot push or open issues or pull requests.
ipxe/src/include/gpxe/interface.h
Michael Brown b1755462ab Do not hold self-references. This then avoids the problem of having to
ensure that we only drop our self-reference exactly once.

To maintain the guarantee that an object won't go out of scope
unexpectedly while one of its event handlers is being called, the
event-calling functions now automatically obtain and drop extra
references.
2007-05-15 16:53:46 +00:00

57 lines
1.2 KiB
C

#ifndef _GPXE_INTERFACE_H
#define _GPXE_INTERFACE_H
/** @file
*
* Object communication interfaces
*
*/
#include <gpxe/refcnt.h>
/** An object communication interface */
struct interface {
/** Destination interface
*
* When messages are sent via this interface, they will be
* delivered to the destination interface.
*
* This pointer may never be NULL. When the interface is
* unplugged, it should point to a null interface.
*/
struct interface *dest;
/** Reference counter
*
* If this interface is not part of a reference-counted
* object, this field may be NULL.
*/
struct refcnt *refcnt;
};
/**
* Increment reference count on an interface
*
* @v intf Interface
* @ret intf Interface
*/
static inline __attribute__ (( always_inline )) struct interface *
intf_get ( struct interface *intf ) {
ref_get ( intf->refcnt );
return intf;
}
/**
* Decrement reference count on an interface
*
* @v intf Interface
*/
static inline __attribute__ (( always_inline )) void
intf_put ( struct interface *intf ) {
ref_put ( intf->refcnt );
}
extern void plug ( struct interface *intf, struct interface *dest );
extern void plug_plug ( struct interface *a, struct interface *b );
#endif /* _GPXE_INTERFACE_H */