home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / WEBSERVE / PI3 / PI3WEB.EXE / DEVEL / INCLUDE / PISync.h < prev    next >
C/C++ Source or Header  |  1997-10-19  |  6KB  |  192 lines

  1. /*____________________________________________________________________________*\
  2.  *
  3.  
  4.  Copyright (c) 1997 John Roy. All rights reserved.
  5.  
  6.  These sources, libraries and applications are
  7.  FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
  8.  as long as the following conditions are adhered to.
  9.  
  10.  Redistribution and use in source and binary forms, with or without
  11.  modification, are permitted provided that the following conditions
  12.  are met:
  13.  
  14.  1. Redistributions of source code must retain the above copyright
  15.     notice, this list of conditions and the following disclaimer. 
  16.  
  17.  2. Redistributions in binary form must reproduce the above copyright
  18.     notice, this list of conditions and the following disclaimer in
  19.     the documentation and/or other materials provided with the
  20.     distribution.
  21.  
  22.  3. Redistributions of any form whatsoever and all advertising materials 
  23.     mentioning features must contain the following
  24.     acknowledgment:
  25.     "This product includes software developed by John Roy
  26.     (http://www.johnroy.com/pi3/)."
  27.  
  28.  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  29.  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30.  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  31.  IN NO EVENT SHALL THE AUTHORS OR ITS CONTRIBUTORS BE LIABLE FOR ANY
  32.  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  33.  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  34.  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35.  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  36.  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  37.  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  38.  OF THE POSSIBILITY OF SUCH DAMAGE.
  39.  
  40.  *____________________________________________________________________________*|
  41.  *
  42.  * $Source: PISync.h$
  43.  * $Date: Sun Aug 10 06:29:38 1997$
  44.  *
  45.  Description:
  46.     Definition of synchronization objects and methods.
  47. \*____________________________________________________________________________*/
  48. /* $HeaderTop:$ */
  49.  
  50. #ifndef PISYNC_H_
  51. #define PISYNC_H_
  52.  
  53. #include "PiAPI.h"
  54.  
  55. /*____________________________________________________________________________*\
  56.  *
  57.  Typedefs:
  58. \*____________________________________________________________________________*/
  59. typedef struct Semaphore PISync;
  60.  
  61. /*____________________________________________________________________________*\
  62.  *
  63.  Name:
  64.     PISync_lock
  65.  
  66.  Synopsis:
  67.     int PISync_lock( PISync *pSync )
  68.     
  69.  Description:
  70.     Attempts to grap a mutex resource or increment the count on a 
  71.     semaphore resource. If the lock cannot be obtained PISync_lock() will
  72.     block until it is obtained.
  73.  
  74.  Notes:
  75.     The behaviour of PISync_lock depends on the type of the synchronization
  76.     object pSync. 
  77.  
  78.     PISync_delete() should be used to destroy a synchronization object when
  79.     it is no longer needed.
  80.  
  81.  Return Values:
  82.     PISync_lock returns zero (PIAPI_COMPLETED) on success.
  83.  
  84.  Errors:
  85.     PIAPI_ERROR            an error occurred.
  86.  
  87.     PIPlatform_getLastError() can be used to obtain more detailed
  88.     error information.
  89.  
  90.  See Also:
  91.     PISync_lock(), PISync_tryLock(), PISync_unlock().
  92. \*____________________________________________________________________________*/
  93. PUBLIC_PIAPI int PISync_lock( PISync *pSync );
  94.  
  95. /*____________________________________________________________________________*\
  96.  *
  97.  Name:
  98.     PISync_tryLock
  99.  
  100.  Synopsis:
  101.     int PISync_tryLock( PISync *pSync )
  102.     
  103.  Description:
  104.     Attempts to grap a mutex resource or increment the count on a 
  105.     semaphore resource. If the lock cannot be immediately obtained
  106.     PISync_lock() will return without blocking.
  107.  
  108.  Notes:
  109.     The behaviour of PISync_tryLock depends on the type of the synchronization
  110.     object pSync. 
  111.  
  112.     PISync_delete() should be used to destroy a synchronization object when
  113.     it is no longer needed.
  114.  
  115.  Return Values:
  116.     PISync_lock returns zero (PIAPI_COMPLETED) if the lock was obtained or
  117.     PIAPI_WOULDBLOCK if the lock could not be obtained.
  118.  
  119.  Errors:
  120.     PIAPI_ERROR            an error occurred.
  121.  
  122.     PIPlatform_getLastError() can be used to obtain more detailed error
  123.     information.
  124.  
  125.  See Also:
  126.     PISync_lock(), PISync_tryLock(), PISync_unlock().
  127. \*____________________________________________________________________________*/
  128. PUBLIC_PIAPI int PISync_tryLock( PISync *pSync );
  129.  
  130. /*____________________________________________________________________________*\
  131.  *
  132.  Name:
  133.     PISync_unlock
  134.  
  135.  Synopsis:
  136.     int PISync_unlock( PISync *pSync )
  137.     
  138.  Description:
  139.     Free's a lock that was placed on a mutex synchronization object or
  140.     increments the free count of a semaphore synchronization object. This
  141.     function removes the lock placed by PISync_lock() or PISync_tryLock().
  142.  
  143.  Notes:
  144.     The behaviour of PISync_unlock depends on the type of the synchronization
  145.     object pSync. 
  146.  
  147.     PISync_delete() should be used to destroy a synchronization object when
  148.     it is no longer needed.
  149.  
  150.  Return Values:
  151.     PISync_unlock returns zero (PIAPI_COMPLETED) on success.
  152.  
  153.  Errors:
  154.     PIAPI_ERROR            an error occurred.
  155.  
  156.     PIPlatform_getLastError() can be used to obtain more detailed error
  157.     information.
  158.  
  159.  See Also:
  160.     PISync_lock(), PISync_tryLock(), PISync_unlock().
  161. \*____________________________________________________________________________*/
  162. PUBLIC_PIAPI int PISync_unlock( PISync *pSync );
  163.  
  164. /*____________________________________________________________________________*\
  165.  *
  166.  Name:
  167.     PISync_delete
  168.  
  169.  Synopsis:
  170.     int PISync_delete( PISync *pSync )
  171.     
  172.  Description:
  173.     Destroy's a synchronization object. 
  174.  
  175.  Notes:
  176.  Return Values:
  177.     PISync_delete returns zero (PIAPI_COMPLETED) on success.
  178.  
  179.  Errors:
  180.     PIAPI_ERROR            an error occurred.
  181.  
  182.     PIPlatform_getLastError() can be used to obtain more detailed error
  183.     information.
  184.  
  185.  See Also:
  186.     PIPlatform_allocLocalMutex(), PIPlatform_allocLocalSemaphore().
  187. \*____________________________________________________________________________*/
  188. PUBLIC_PIAPI int PISync_delete( PISync *pSync );
  189.  
  190. #endif    /* PISYNC_H_ */
  191.  
  192.