Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
ee95a6f9
Commit
ee95a6f9
authored
Mar 18, 2014
by
David COME
Browse files
Added interface for DiskXThreadPool
and refactor a bit of code into the interface
parent
b1840206
Changes
3
Hide whitespace changes
Inline
Side-by-side
castor/tape/tapeserver/daemon/DiskReadThreadPool.hpp
View file @
ee95a6f9
...
...
@@ -27,9 +27,10 @@
#include
"castor/tape/tapeserver/daemon/DiskReadTask.hpp"
#include
"castor/tape/tapeserver/threading/BlockingQueue.hpp"
#include
"castor/tape/tapeserver/threading/Threading.hpp"
#include
"DiskThreadPoolInterface.hpp"
#include
<vector>
class
DiskReadThreadPool
{
class
DiskReadThreadPool
:
public
castor
::
tape
::
tapeserver
::
daemon
::
DiskThreadPoolInterface
<
DiskReadTask
>
{
public:
DiskReadThreadPool
(
int
nbThread
)
{
for
(
int
i
=
0
;
i
<
nbThread
;
i
++
)
{
...
...
@@ -55,7 +56,7 @@ public:
(
*
i
)
->
waitThreads
();
}
}
void
push
(
DiskReadTask
*
t
)
{
m_tasks
.
push
(
t
);
}
virtual
void
push
(
DiskReadTask
*
t
)
{
m_tasks
.
push
(
t
);
}
void
finish
()
{
/* Insert one endOfSession per thread */
for
(
size_t
i
=
0
;
i
<
m_threads
.
size
();
i
++
)
{
...
...
@@ -64,9 +65,6 @@ public:
}
private:
class
endOfSession
:
public
DiskReadTask
{
virtual
bool
endOfWork
()
{
return
true
;
}
};
class
DiskReadWorkerThread
:
private
castor
::
tape
::
threading
::
Thread
{
public:
DiskReadWorkerThread
(
DiskReadThreadPool
&
manager
)
:
m_manager
(
manager
)
{}
...
...
castor/tape/tapeserver/daemon/DiskThreadPoolInterface.hpp
0 → 100644
View file @
ee95a6f9
/*
* File: DiskThreadPoolInterface.h
* Author: dcome
*
* Created on March 18, 2014, 3:53 PM
*/
#ifndef DISKTHREADPOOLINTERFACE_H
#define DISKTHREADPOOLINTERFACE_H
namespace
castor
{
namespace
tape
{
namespace
tapeserver
{
namespace
daemon
{
template
<
class
Task
>
class
DiskThreadPoolInterface
{
protected
:
class
endOfSession
:
public
Task
{
virtual
bool
endOfWork
()
{
return
true
;
}
};
castor
::
tape
::
threading
::
BlockingQueue
<
Task
*>
m_tasks
;
public
:
virtual
~
DiskThreadPoolInterface
(){}
virtual
void
push
(
Task
*
t
)
=
0
;
};
}}}}
#endif
/* DISKTHREADPOOLINTERFACE_H */
castor/tape/tapeserver/daemon/DiskWriteThreadPool.hpp
View file @
ee95a6f9
...
...
@@ -28,9 +28,10 @@
#include
"castor/tape/tapeserver/threading/BlockingQueue.hpp"
#include
"castor/tape/tapeserver/threading/Threading.hpp"
#include
"castor/tape/tapeserver/daemon/TaskInjector.hpp"
#include
"DiskThreadPoolInterface.hpp"
#include
<vector>
class
DiskWriteThreadPool
{
class
DiskWriteThreadPool
:
public
castor
::
tape
::
tapeserver
::
daemon
::
DiskThreadPoolInterface
<
DiskWriteTask
>
{
public:
DiskWriteThreadPool
(
int
nbThread
,
int
maxFilesReq
,
int
maxBlocksReq
)
:
m_jobInjector
(
NULL
),
m_filesQueued
(
0
),
m_blocksQueued
(
0
),
...
...
@@ -59,7 +60,7 @@ public:
(
*
i
)
->
waitThreads
();
}
}
void
push
(
DiskWriteTask
*
t
)
{
virtual
void
push
(
DiskWriteTask
*
t
)
{
{
castor
::
tape
::
threading
::
MutexLocker
ml
(
&
m_counterProtection
);
m_filesQueued
+=
t
->
files
();
...
...
@@ -112,9 +113,6 @@ private:
return
ret
;
}
class
endOfSession
:
public
DiskWriteTask
{
virtual
bool
endOfWork
()
{
return
true
;
}
};
class
DiskWriteWorkerThread
:
private
castor
::
tape
::
threading
::
Thread
{
public:
DiskWriteWorkerThread
(
DiskWriteThreadPool
&
manager
)
:
m_manager
(
manager
)
{}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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