ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
trequest.hpp
Go to the documentation of this file.
1/** ************************************************************************************************
2 * \file
3 * This header file is part of module \alib_threads of the \aliblong.
4 *
5 * \emoji :copyright: 2013-2019 A-Worx GmbH, Germany.
6 * Published under \ref mainpage_license "Boost Software License".
7 **************************************************************************************************/
8#ifndef HPP_AWORX_ALIB_THREADS_MODEL_TREQUEST
9#define HPP_AWORX_ALIB_THREADS_MODEL_TREQUEST
10
11
12#if !defined(ALIB_DOX) // todo remove
13
14
15#if !defined (HPP_ALIB_THREADS_THREADLOCK)
17#endif
18
19
20#include <semaphore.h>
21
22namespace alib { namespace threads::model {
23
24/** ************************************************************************************************
25 * TODOX
26 * TODO(240316 08:42):
27 * We should have a dedicated allocator for all thread things.
28 * Then, a hashtable should use RTTI to recycle TRequest objects. Thus, those objects are
29 * always created using the ThreadManager interface (or wherever this goes) and likewise
30 * destroyed. When destroyed, they are added to the type-dependend recycling list found in
31 * the hashtable.
32 * Or: rather use "sizeof" instead of RTTI!
33 **************************************************************************************************/
34class TRequest
35{
36 public: // todo: use std::future with a std::promise
37 TRequest(void* data= nullptr);
38 virtual ~TRequest();
39 bool isProcessed();
40 bool waitUntilProcessed(int millisecs= -1);
41 void setProcessed();
42
43public:
44 int status;
45 void* data;
46 void* data2;
47
48 sem_t event; // with Posix we implement it with a real semaphore
49 alib::ThreadLock lock; // sync the semaphore access
50};
51
52} // namespace alib[::threads::model]
53
54/// Type alias in namespace #aworx.
55using TRequest = alib::threads::model::TRequest;
56
57
58} // namespace [alib]
59
60
61#endif // !defined(ALIB_DOX)
62
63#endif // HPP_AWORX_ALIB_THREADS_MODEL_TREQUEST
Definition alib.cpp:57