Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
4edd8795
Commit
4edd8795
authored
Nov 18, 2012
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Turned linker into a single implementation component.
parent
e7baa766
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
110 deletions
+31
-110
linker.h
dlib/linker.h
+0
-28
linker_kernel_1.cpp
dlib/linker/linker_kernel_1.cpp
+19
-11
linker_kernel_1.h
dlib/linker/linker_kernel_1.h
+12
-7
linker_kernel_abstract.h
dlib/linker/linker_kernel_abstract.h
+0
-1
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
ai
ted with running_mutex
running_signaler == a signaler assoc
ia
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