Annotation of embedaddon/libpdel/util/mesg_port.3, revision 1.1
1.1 ! misho 1: .\" Copyright (c) 2001-2002 Packet Design, LLC.
! 2: .\" All rights reserved.
! 3: .\"
! 4: .\" Subject to the following obligations and disclaimer of warranty,
! 5: .\" use and redistribution of this software, in source or object code
! 6: .\" forms, with or without modifications are expressly permitted by
! 7: .\" Packet Design; provided, however, that:
! 8: .\"
! 9: .\" (i) Any and all reproductions of the source or object code
! 10: .\" must include the copyright notice above and the following
! 11: .\" disclaimer of warranties; and
! 12: .\" (ii) No rights are granted, in any manner or form, to use
! 13: .\" Packet Design trademarks, including the mark "PACKET DESIGN"
! 14: .\" on advertising, endorsements, or otherwise except as such
! 15: .\" appears in the above copyright notice or in the software.
! 16: .\"
! 17: .\" THIS SOFTWARE IS BEING PROVIDED BY PACKET DESIGN "AS IS", AND
! 18: .\" TO THE MAXIMUM EXTENT PERMITTED BY LAW, PACKET DESIGN MAKES NO
! 19: .\" REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING
! 20: .\" THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED
! 21: .\" WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
! 22: .\" OR NON-INFRINGEMENT. PACKET DESIGN DOES NOT WARRANT, GUARANTEE,
! 23: .\" OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS
! 24: .\" OF THE USE OF THIS SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY,
! 25: .\" RELIABILITY OR OTHERWISE. IN NO EVENT SHALL PACKET DESIGN BE
! 26: .\" LIABLE FOR ANY DAMAGES RESULTING FROM OR ARISING OUT OF ANY USE
! 27: .\" OF THIS SOFTWARE, INCLUDING WITHOUT LIMITATION, ANY DIRECT,
! 28: .\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE, OR CONSEQUENTIAL
! 29: .\" DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, LOSS OF
! 30: .\" USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY THEORY OF
! 31: .\" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 32: .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
! 33: .\" THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF
! 34: .\" THE POSSIBILITY OF SUCH DAMAGE.
! 35: .\"
! 36: .\" Author: Archie Cobbs <archie@freebsd.org>
! 37: .\"
! 38: .\" $Id: mesg_port.3,v 1.7 2004/06/02 17:24:38 archie Exp $
! 39: .\"
! 40: .Dd April 22, 2002
! 41: .Dt MESG_PORT 3
! 42: .Os
! 43: .Sh NAME
! 44: .Nm mesg_port
! 45: .Nd generic message ports
! 46: .Sh LIBRARY
! 47: PDEL Library (libpdel, \-lpdel)
! 48: .Sh SYNOPSIS
! 49: .In pthread.h
! 50: .In pdel/util/mesg_port.h
! 51: .Ft "struct mesg_port *"
! 52: .Fn mesg_port_create "const char *mtype"
! 53: .Ft void
! 54: .Fn mesg_port_destroy "struct mesg_port **portp"
! 55: .Ft int
! 56: .Fn mesg_port_put "struct mesg_port *port" "void *data"
! 57: .Ft "void *"
! 58: .Fn mesg_port_get "struct mesg_port *port" "int timeout"
! 59: .Ft u_int
! 60: .Fn mesg_port_qlen "struct mesg_port *port"
! 61: .Sh DESCRIPTION
! 62: These functions implement a message port for inter-thread communication.
! 63: .Pp
! 64: .Fn mesg_port_create
! 65: creates a new messge port, using
! 66: .Xr typed_mem 3
! 67: type
! 68: .Fa mtype
! 69: for internal memory allocation.
! 70: .Pp
! 71: .Fn mesg_port_destroy
! 72: destroys the message port pointed to by
! 73: .Fa "*portp" .
! 74: There must be no messages in the message port, otherwise
! 75: .Fn mesg_port_destroy
! 76: aborts with an assertion failure.
! 77: Upon return,
! 78: .Fa "*portp"
! 79: will be set to
! 80: .Dv NULL .
! 81: If
! 82: .Fa "*portp"
! 83: is already
! 84: .Dv NULL
! 85: when
! 86: .Fn mesg_port_destroy
! 87: is invoked, nothing happens.
! 88: .Pp
! 89: .Fn mesg_port_put
! 90: writes the message represented by
! 91: .Fa data
! 92: to the message port pointed to by
! 93: .Fa port .
! 94: The
! 95: .Fa data
! 96: may not be
! 97: .Dv NULL .
! 98: .Pp
! 99: .Fn mesg_port_get
! 100: retrieves the next available message written to the message port pointed to by
! 101: .Fa port .
! 102: Messages are read in the same order as they are written.
! 103: If there are no messages,
! 104: .Fn mesg_port_get
! 105: waits for up to
! 106: .Fa timeout
! 107: milliseconds, or indefinitely if
! 108: .Fa timeout
! 109: is negative.
! 110: The thread calling
! 111: .Fn mesg_port_get
! 112: may be canceled without ill effect.
! 113: .Pp
! 114: .Fn mesg_port_qlen
! 115: returns the current number of messages queued on the message port pointed to by
! 116: .Fa port .
! 117: .Pp
! 118: .Fn mesg_port_put ,
! 119: .Fn mesg_port_get ,
! 120: and
! 121: .Fn mesg_port_qlen
! 122: may be called safely at the same time from different threads.
! 123: .Sh RETURN VALUES
! 124: .Fn mesg_port_create ,
! 125: .Fn mesg_port_put ,
! 126: and
! 127: .Fn mesg_port_get
! 128: return
! 129: .Dv NULL
! 130: or -1 to indicate an error,
! 131: with
! 132: .Va errno
! 133: set appropriately.
! 134: .Sh SEE ALSO
! 135: .Xr libpdel 3 ,
! 136: .Xr pevent 3 ,
! 137: .Xr pthread 3 ,
! 138: .Xr typed_mem 3
! 139: .Sh HISTORY
! 140: The PDEL library was developed at Packet Design, LLC.
! 141: .Dv "http://www.packetdesign.com/"
! 142: .Sh AUTHORS
! 143: .An Archie Cobbs Aq archie@freebsd.org
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>