LibreOffice Module cppu (master) 1
jobqueue.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#pragma once
21
22#include <sal/config.h>
23
24#include <condition_variable>
25#include <deque>
26#include <memory>
27#include <mutex>
28
29#include <sal/types.h>
30
31namespace cppu_threadpool
32{
33 extern "C" typedef void (RequestFun)(void *);
34
35 struct Job
36 {
39 };
40
42 typedef std::shared_ptr<DisposedCallerAdmin> DisposedCallerAdminHolder;
43
45 {
46 public:
47 JobQueue();
48
49 void add( void *pThreadSpecificData, RequestFun * doRequest );
50
51 void *enter( void const * nDisposeId , bool bReturnWhenNoJob = false );
52 void dispose( void const * nDisposeId );
53
54 void suspend();
55 void resume();
56
57 bool isEmpty() const;
58 bool isCallstackEmpty() const;
59 bool isBusy() const;
60
61 private:
62 mutable std::mutex m_mutex;
63 std::deque < struct Job > m_lstJob;
64 std::deque<void const *> m_lstCallstack;
65 sal_Int32 m_nToDo;
67 std::condition_variable m_cndWait;
69 };
70}
71
72/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void dispose(void const *nDisposeId)
Definition: jobqueue.cxx:122
std::deque< struct Job > m_lstJob
Definition: jobqueue.hxx:63
void * enter(void const *nDisposeId, bool bReturnWhenNoJob=false)
Definition: jobqueue.cxx:48
std::deque< void const * > m_lstCallstack
Definition: jobqueue.hxx:64
void add(void *pThreadSpecificData, RequestFun *doRequest)
Definition: jobqueue.cxx:36
std::condition_variable m_cndWait
Definition: jobqueue.hxx:67
DisposedCallerAdminHolder m_DisposedCallerAdmin
Definition: jobqueue.hxx:68
bool isCallstackEmpty() const
Definition: jobqueue.cxx:162
std::shared_ptr< DisposedCallerAdmin > DisposedCallerAdminHolder
Definition: jobqueue.hxx:41
void() RequestFun(void *)
Definition: jobqueue.hxx:33
void * pThreadSpecificData
Definition: jobqueue.hxx:37
RequestFun * doRequest
Definition: jobqueue.hxx:38