xref: /freebsd/crypto/krb5/src/ccapi/server/win/WorkQueue.cpp (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1 /*
2  * $Header$
3  *
4  * Copyright 2008 Massachusetts Institute of Technology.
5  * All Rights Reserved.
6  *
7  * Export of this software from the United States of America may
8  * require a specific license from the United States Government.
9  * It is the responsibility of any person or organization contemplating
10  * export to obtain such a license before exporting.
11  *
12  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13  * distribute this software and its documentation for any purpose and
14  * without fee is hereby granted, provided that the above copyright
15  * notice appear in all copies and that both that copyright notice and
16  * this permission notice appear in supporting documentation, and that
17  * the name of M.I.T. not be used in advertising or publicity pertaining
18  * to distribution of the software without specific, written prior
19  * permission.  Furthermore if you modify this software you must label
20  * your software as modified software and not distribute it in such a
21  * fashion that it might be confused with the original M.I.T. software.
22  * M.I.T. makes no representations about the suitability of
23  * this software for any purpose.  It is provided "as is" without express
24  * or implied warranty.
25  */
26 
27 #include "WorkQueue.h"
28 extern "C" {
29     #include "cci_debugging.h"
30     }
31 
32 #include "WorkItem.h"
33 
34 WorkList    worklist;
35 
worklist_initialize()36 EXTERN_C    int worklist_initialize() {
37         return worklist.initialize();
38         }
39 
worklist_cleanup()40 EXTERN_C    int worklist_cleanup() {
41         return worklist.cleanup();
42         }
43 
worklist_wait()44 EXTERN_C    void worklist_wait() {
45         worklist.wait();
46         }
47 
48 /* C interfaces: */
worklist_isEmpty()49 EXTERN_C    BOOL worklist_isEmpty() {
50         return worklist.isEmpty() ? TRUE : FALSE;
51         }
52 
worklist_add(const long rpcmsg,const ccs_pipe_t pipe,const k5_ipc_stream stream,const time_t serverStartTime)53 EXTERN_C    int worklist_add(   const long          rpcmsg,
54                                 const ccs_pipe_t    pipe,
55                                 const k5_ipc_stream stream,
56                                 const time_t        serverStartTime) {
57         return worklist.add(new WorkItem(stream, pipe, rpcmsg, serverStartTime) );
58         }
59 
worklist_remove(long * rpcmsg,ccs_pipe_t * pipe,k5_ipc_stream * stream,time_t * sst)60 EXTERN_C    int  worklist_remove(long*              rpcmsg,
61                                  ccs_pipe_t*        pipe,
62                                  k5_ipc_stream*      stream,
63                                  time_t*            sst) {
64         WorkItem*   item    = NULL;
65         cc_int32    err     = worklist.remove(&item);
66 
67         *rpcmsg         = item->type();
68         *pipe           = item->take_pipe();
69         *stream         = item->take_payload();
70         *sst            = item->sst();
71         delete item;
72         return err;
73         }
74 
75