mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 13:18:50 +08:00
Add nx_eventnotify.c
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1349 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
f48db4efac
commit
fccb66a0be
3 changed files with 150 additions and 9 deletions
|
@ -35,7 +35,7 @@
|
|||
|
||||
NX_ASRCS =
|
||||
NXAPI_CSRCS = nx_bitmap.c nx_closewindow.c nx_connect.c nx_disconnect.c \
|
||||
nx_eventhandler.c nx_fill.c nx_filltrapezoid.c \
|
||||
nx_eventhandler.c nx_eventnotify.c nx_fill.c nx_filltrapezoid.c \
|
||||
nx_getposition.c nx_kbdchin.c nx_kbdin.c nx_lower.c \
|
||||
nx_mousein.c nx_move.c nx_openwindow.c nx_raise.c \
|
||||
nx_releasebkgd.c nx_requestbkgd.c nx_setsize.c \
|
||||
|
|
109
graphics/nxmu/nx_eventnotify.c
Normal file
109
graphics/nxmu/nx_eventnotify.c
Normal file
|
@ -0,0 +1,109 @@
|
|||
/****************************************************************************
|
||||
* graphics/nxmu/nx_eventnotify.c
|
||||
*
|
||||
* Copyright (C) 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <mqueue.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/nx.h>
|
||||
#include "nxfe.h"
|
||||
|
||||
#ifndef CONFIG_DISABLE_SIGNALS
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-Processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_eventnotify
|
||||
*
|
||||
* Description:
|
||||
* Rather than calling nx_eventhandler periodically, the client may
|
||||
* register to receive a signal when a server event is available. The
|
||||
* client can then call nv_eventhandler() only when incoming events are
|
||||
* available.
|
||||
*
|
||||
* Input Parameters:
|
||||
* handle - the handle returned by nx_connect
|
||||
*
|
||||
* Return:
|
||||
* OK: No errors occurred. If CONFIG_NX_BLOCKING is defined, then
|
||||
* one or more server message was processed.
|
||||
* ERROR: An error occurred and errno has been set appropriately
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int nx_eventnotify(NXHANDLE handle, int signo)
|
||||
{
|
||||
FAR struct nxfe_conn_s *conn = (FAR struct nxfe_conn_s *)handle;
|
||||
struct sigevent se;
|
||||
|
||||
se.sigev_notify = SIGEV_SIGNAL;
|
||||
se.sigev_signo = signo;
|
||||
se.sigev_value.sival_ptr = (FAR void *)handle;
|
||||
|
||||
return mq_notify(conn->crdmq, &se);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_DISABLE_SIGNALS */
|
|
@ -321,24 +321,56 @@ EXTERN void nx_close(NXHANDLE handle);
|
|||
* Description:
|
||||
* The client code must call this function periodically to process
|
||||
* incoming messages from the server. If CONFIG_NX_BLOCKING is defined,
|
||||
* then this function will never return until the host is disconnected.
|
||||
* then this function not return until a server message is received.
|
||||
*
|
||||
* When CONFIG_NX_BLOCKING is not defined, the client must exercise
|
||||
* caution in the looping to assure that it does not eat up all of
|
||||
* the CPU bandwidth calling nx_eventhandler repeatedly. nx_eventnotify
|
||||
* may be called to get a signal event whenever a new incoming server
|
||||
* event is avaiable.
|
||||
*
|
||||
* Input Parameters:
|
||||
* handle - the handle returned by nx_connect
|
||||
*
|
||||
* Return:
|
||||
* >0: The length of the message received in msgbuffer
|
||||
* 0: No message was received
|
||||
* <0: An error occurred and errno has been set appropriately
|
||||
*
|
||||
* Of particular interest, it will return errno == EHOSTDOWN when the
|
||||
* server is disconnected. After that event, the handle can not longer
|
||||
* be used.
|
||||
* OK: No errors occurred. If CONFIG_NX_BLOCKING is defined, then
|
||||
* one or more server message was processed.
|
||||
* ERROR: An error occurred and errno has been set appropriately. Of
|
||||
* particular interest, it will return errno == EHOSTDOWN when the
|
||||
* server is disconnected. After that event, the handle can no
|
||||
* longer be used.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NX_MULTIUSER
|
||||
EXTERN int nx_eventhandler(NXHANDLE handle);
|
||||
#else
|
||||
# define nx_eventhandler(handle) (OK)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nx_eventnotify
|
||||
*
|
||||
* Description:
|
||||
* Rather than calling nx_eventhandler periodically, the client may
|
||||
* register to receive a signal when a server event is available. The
|
||||
* client can then call nv_eventhandler() only when incoming events are
|
||||
* available.
|
||||
*
|
||||
* Input Parameters:
|
||||
* handle - the handle returned by nx_connect
|
||||
*
|
||||
* Return:
|
||||
* OK: No errors occurred. If CONFIG_NX_BLOCKING is defined, then
|
||||
* one or more server message was processed.
|
||||
* ERROR: An error occurred and errno has been set appropriately
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NX_MULTIUSER) && !defined(CONFIG_DISABLE_SIGNALS)
|
||||
EXTERN int nx_eventnotify(NXHANDLE handle, int signo);
|
||||
#else
|
||||
# define nx_eventnotify(handle, signo) (OK)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
|
|
Loading…
Reference in a new issue