OpenDDS
Snapshot(2023/04/28-20:55)
dds
DCPS
transport
framework
ThreadSynch.h
Go to the documentation of this file.
1
/*
2
*
3
*
4
* Distributed under the OpenDDS License.
5
* See: http://www.opendds.org/license.html
6
*/
7
8
#ifndef OPENDDS_DCPS_TRANSPORT_FRAMEWORK_THREADSYNCH_H
9
#define OPENDDS_DCPS_TRANSPORT_FRAMEWORK_THREADSYNCH_H
10
11
#include "
dds/DCPS/dcps_export.h
"
12
#include "
ThreadSynchWorker.h
"
13
#include "
dds/DCPS/PoolAllocationBase.h
"
14
#include "
dds/DCPS/unique_ptr.h
"
15
16
OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
17
18
namespace
OpenDDS
{
19
namespace
DCPS {
20
21
class
ThreadSynchResource;
22
23
/**
24
* This class is the base class for different ThreadSynch stratege, currently
25
* only the thread per connection strategy is implemented and used.
26
*
27
* Notes for object ownership:
28
* 1) Pointer to TransportSendStrategy object (as ThreadSynchWorker) directly but not
29
* reference counted. It won't have access problem during it lifetime because the
30
* TransportSendStrategy object owns this ThreadSynch object.
31
* 2) The ThreadSynch object is created by the ThreadSynchResource object and it owns
32
* the ThreadSynchResource object.
33
*/
34
class
OpenDDS_Dcps_Export
ThreadSynch
:
public
PoolAllocationBase
{
35
public
:
36
37
virtual
~
ThreadSynch
();
38
39
/// The worker must introduce himself to this ThreadSynch object.
40
/// It is the worker object that "owns" this ThreadSynch object.
41
/// Returns 0 for success, -1 for failure.
42
int
register_worker(
ThreadSynchWorker
& worker);
43
44
/// Our owner, the worker_, is breaking our relationship.
45
void
unregister_worker();
46
47
/// The ThreadSynchWorker would like to have its perform_work() called
48
/// from the appropriate thread once the ThreadSynchResource claims
49
/// that it is_ready_for_work().
50
virtual
void
work_available() = 0;
51
52
protected
:
53
54
// This ThreadSynch object takes ownership of the resource.
55
ThreadSynch
(
ThreadSynchResource
* resource);
56
57
int
wait_on_clogged_resource();
58
59
/// The default implementation is to do nothing here. The
60
/// subclass may override the implementation in order to do
61
/// something when the worker registers.
62
/// Returns 0 for success, -1 for failure.
63
virtual
int
register_worker_i();
64
65
/// The default implementation is to do nothing here. The
66
/// subclass may override the implementation in order to do
67
/// something when the worker unregisters.
68
virtual
void
unregister_worker_i();
69
70
/// Access the worker implementation directly.
71
WeakRcHandle<ThreadSynchWorker>
worker();
72
73
private
:
74
WeakRcHandle<ThreadSynchWorker>
worker_
;
75
unique_ptr<ThreadSynchResource>
resource_
;
76
};
77
78
}
// namespace DCPS
79
}
// namespace OpenDDS
80
81
OPENDDS_END_VERSIONED_NAMESPACE_DECL
82
83
#if defined (__ACE_INLINE__)
84
#include "
ThreadSynch.inl
"
85
#endif
/* __ACE_INLINE__ */
86
87
#endif
/* OPENDDS_DCPS_THREADSYNCH_H */
OpenDDS::DCPS::unique_ptr
Definition:
unique_ptr.h:64
dcps_export.h
OpenDDS_Dcps_Export
#define OpenDDS_Dcps_Export
Definition:
dcps_export.h:24
ThreadSynch.inl
PoolAllocationBase.h
OpenDDS::DCPS::WeakRcHandle
Definition:
RcObject.h:127
OpenDDS::DCPS::ThreadSynch::resource_
unique_ptr< ThreadSynchResource > resource_
Definition:
ThreadSynch.h:75
ThreadSynchWorker.h
unique_ptr.h
OpenDDS::DCPS::ThreadSynchResource
Definition:
ThreadSynchResource.h:19
OPENDDS_END_VERSIONED_NAMESPACE_DECL
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
Definition:
Versioned_Namespace.h:48
OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
Definition:
Hash.cpp:17
OpenDDS::DCPS::PoolAllocationBase
Definition:
PoolAllocationBase.h:60
OpenDDS::DCPS::ThreadSynch::worker_
WeakRcHandle< ThreadSynchWorker > worker_
Definition:
ThreadSynch.h:74
OpenDDS
The Internal API and Implementation of OpenDDS.
Definition:
AddressCache.h:28
OpenDDS::DCPS::ThreadSynchWorker
Definition:
ThreadSynchWorker.h:22
OpenDDS::DCPS::ThreadSynch
Definition:
ThreadSynch.h:34
Generated by
1.8.13