Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
4edd8795
Commit
4edd8795
authored
Nov 18, 2012
by
Davis King
Browse files
Turned linker into a single implementation component.
parent
e7baa766
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
110 deletions
+31
-110
dlib/linker.h
dlib/linker.h
+0
-28
dlib/linker/linker_kernel_1.cpp
dlib/linker/linker_kernel_1.cpp
+19
-11
dlib/linker/linker_kernel_1.h
dlib/linker/linker_kernel_1.h
+12
-7
dlib/linker/linker_kernel_abstract.h
dlib/linker/linker_kernel_abstract.h
+0
-1
dlib/linker/linker_kernel_c.h
dlib/linker/linker_kernel_c.h
+0
-63
No files found.
dlib/linker.h
View file @
4edd8795
...
...
@@ -4,34 +4,6 @@
#define DLIB_LINKEr_
#include "linker/linker_kernel_1.h"
#include "linker/linker_kernel_c.h"
#include "algs.h"
namespace
dlib
{
class
linker
{
linker
()
{}
public:
//----------- kernels ---------------
// kernel_1a
typedef
linker_kernel_1
kernel_1a
;
typedef
linker_kernel_c
<
kernel_1a
>
kernel_1a_c
;
};
}
#endif // DLIB_LINKEr_
dlib/linker/linker_kernel_1.cpp
View file @
4edd8795
...
...
@@ -13,8 +13,8 @@ namespace dlib
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
linker
_kernel_1
::
linker
_kernel_1
(
linker
::
linker
(
)
:
running
(
false
),
running_signaler
(
running_mutex
),
...
...
@@ -26,8 +26,8 @@ namespace dlib
// ----------------------------------------------------------------------------------------
linker
_kernel_1
::
~
linker
_kernel_1
(
linker
::
~
linker
(
)
{
clear
();
...
...
@@ -35,7 +35,7 @@ namespace dlib
// ----------------------------------------------------------------------------------------
void
linker
_kernel_1
::
void
linker
::
clear
(
)
{
...
...
@@ -67,7 +67,7 @@ namespace dlib
// ----------------------------------------------------------------------------------------
bool
linker
_kernel_1
::
bool
linker
::
is_running
(
)
const
{
...
...
@@ -79,12 +79,20 @@ namespace dlib
// ----------------------------------------------------------------------------------------
void
linker
_kernel_1
::
void
linker
::
link
(
connection
&
a
,
connection
&
b
)
{
// make sure requires clause is not broken
DLIB_CASSERT
(
this
->
is_running
()
==
false
,
"
\t
void linker::link"
<<
"
\n\t
is_running() == "
<<
this
->
is_running
()
<<
"
\n\t
this: "
<<
this
);
running_mutex
.
lock
();
running
=
true
;
running_mutex
.
unlock
();
...
...
@@ -127,7 +135,7 @@ namespace dlib
throw
dlib
::
thread_error
(
ECREATE_THREAD
,
"failed to make new thread in linker
_kernel_1
::link()"
"failed to make new thread in linker::link()"
);
}
...
...
@@ -219,7 +227,7 @@ namespace dlib
// throw the exception for this error
throw
dlib
::
socket_error
(
ECONNECTION
,
"a connection returned an error in linker
_kernel_1
::link()"
"a connection returned an error in linker::link()"
);
}
...
...
@@ -233,12 +241,12 @@ namespace dlib
// ----------------------------------------------------------------------------------------
void
linker
_kernel_1
::
void
linker
::
service_connection
(
void
*
param
)
{
linker
_kernel_1
&
p
=
*
static_cast
<
linker
_kernel_1
*>
(
param
);
linker
&
p
=
*
static_cast
<
linker
*>
(
param
);
p
.
cons_mutex
.
lock
();
// if the connections are gone for whatever reason then return
...
...
dlib/linker/linker_kernel_1.h
View file @
4edd8795
...
...
@@ -12,7 +12,7 @@
namespace
dlib
{
class
linker
_kernel_1
class
linker
{
/*!
...
...
@@ -21,7 +21,7 @@ namespace dlib
A == 0
B == 0
running_mutex == a mutex
running_signaler == a signaler assoc
a
ited with running_mutex
running_signaler == a signaler associ
a
ted with running_mutex
cons_mutex == a mutex
service_connection_running == false
service_connection_running_mutex == a mutex
...
...
@@ -65,11 +65,16 @@ namespace dlib
public:
// These two typedefs are here for backwards compatibility with previous
// versions of dlib.
typedef
linker
kernel_1a
;
typedef
linker
kernel_1a_c
;
linker_kernel_1
(
linker
(
);
virtual
~
linker
_kernel_1
(
virtual
~
linker
(
);
void
clear
(
...
...
@@ -91,7 +96,7 @@ namespace dlib
);
/*!
requires
param == pointer to a linker
_kernel_1
object
param == pointer to a linker object
ensures
waits for data from b and forwards it to a and
if (b closes normally or is shutdown()) service_connection ends and
...
...
@@ -116,8 +121,8 @@ namespace dlib
mutex
service_connection_error_mutex
;
// restricted functions
linker
_kernel_1
(
linker_kernel_1
&
);
// copy constructor
linker
_kernel_1
&
operator
=
(
linker
_kernel_1
&
);
// assignment operator
linker
(
linker
&
);
// copy constructor
linker
&
operator
=
(
linker
&
);
// assignment operator
};
...
...
dlib/linker/linker_kernel_abstract.h
View file @
4edd8795
...
...
@@ -3,7 +3,6 @@
#undef DLIB_LINKER_KERNEl_ABSTRACT_
#ifdef DLIB_LINKER_KERNEl_ABSTRACT_
// non-templateable dependencies
#include "../threads/threads_kernel_abstract.h"
#include "../sockets/sockets_kernel_abstract.h"
...
...
dlib/linker/linker_kernel_c.h
deleted
100644 → 0
View file @
e7baa766
// Copyright (C) 2003 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#ifndef DLIB_LINKER_KERNEl_C_
#define DLIB_LINKER_KERNEl_C_
#include "linker_kernel_abstract.h"
#include "../sockets.h"
#include "../algs.h"
#include "../assert.h"
namespace
dlib
{
template
<
typename
linker_base
>
class
linker_kernel_c
:
public
linker_base
{
public:
void
link
(
connection
&
a
,
connection
&
b
);
};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// member function definitions
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
linker_base
>
void
linker_kernel_c
<
linker_base
>::
link
(
connection
&
a
,
connection
&
b
)
{
// make sure requires clause is not broken
DLIB_CASSERT
(
this
->
is_running
()
==
false
,
"
\t
void linker::link"
<<
"
\n\t
is_running() == "
<<
this
->
is_running
()
<<
"
\n\t
this: "
<<
this
);
// call the real function
linker_base
::
link
(
a
,
b
);
}
// ----------------------------------------------------------------------------------------
}
#endif // DLIB_LINKER_KERNEl_C_
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment