merged tag ooo/DEV300_m102
[LibreOffice.git] / cppu / source / threadpool / jobqueue.hxx
blob78202573403eb20d0dddc9f4b8cbadb40d490b61
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef _CPPU_THREADPOOL_JOBQUEUE_HXX_
29 #define _CPPU_THREADPOOL_JOBQUEUE_HXX_
31 #include <list>
32 #include <sal/types.h>
34 #include <osl/conditn.h>
35 #include <osl/mutex.hxx>
37 #include <boost/shared_ptr.hpp>
39 namespace cppu_threadpool
41 extern "C" typedef void (SAL_CALL RequestFun)(void *);
43 struct Job
45 void *pThreadSpecificData;
46 RequestFun * doRequest;
49 typedef ::std::list < struct Job > JobList;
51 typedef ::std::list < sal_Int64 > CallStackList;
53 class DisposedCallerAdmin;
54 typedef boost::shared_ptr<DisposedCallerAdmin> DisposedCallerAdminHolder;
56 class JobQueue
58 public:
59 JobQueue();
60 ~JobQueue();
62 void add( void *pThreadSpecificData, RequestFun * doRequest );
64 void *enter( sal_Int64 nDisposeId , sal_Bool bReturnWhenNoJob = sal_False );
65 void dispose( sal_Int64 nDisposeId );
67 void suspend();
68 void resume();
70 sal_Bool isEmpty();
71 sal_Bool isCallstackEmpty();
72 sal_Bool isBusy();
74 private:
75 ::osl::Mutex m_mutex;
76 JobList m_lstJob;
77 CallStackList m_lstCallstack;
78 sal_Int32 m_nToDo;
79 sal_Bool m_bSuspended;
80 oslCondition m_cndWait;
81 DisposedCallerAdminHolder m_DisposedCallerAdmin;
85 #endif