mirror of https://github.com/aria2/aria2
2009-04-26 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added forEachMemFunSH(). Use it in BitTorrent event dispatch. * src/DefaultBtMessageDispatcher.cc * src/a2algo.hpull/1/head
parent
e385c68f52
commit
8a1d530336
|
@ -1,3 +1,9 @@
|
|||
2009-04-26 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Added forEachMemFunSH(). Use it in BitTorrent event dispatch.
|
||||
* src/DefaultBtMessageDispatcher.cc
|
||||
* src/a2algo.h
|
||||
|
||||
2009-04-25 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Removed ExtendedMessagingAware. Instead of using inheritance,
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "LogFactory.h"
|
||||
#include "Logger.h"
|
||||
#include "a2functional.h"
|
||||
#include "a2algo.h"
|
||||
#include "RequestGroupMan.h"
|
||||
#include "RequestGroup.h"
|
||||
|
||||
|
@ -119,9 +120,9 @@ void DefaultBtMessageDispatcher::doCancelSendingPieceAction(size_t index, uint32
|
|||
BtCancelSendingPieceEvent event(index, begin, length);
|
||||
|
||||
BtMessages tempQueue = messageQueue;
|
||||
std::for_each(tempQueue.begin(), tempQueue.end(),
|
||||
std::bind2nd(mem_fun_sh(&BtMessage::onCancelSendingPieceEvent),
|
||||
event));
|
||||
|
||||
forEachMemFunSH(tempQueue.begin(), tempQueue.end(),
|
||||
&BtMessage::onCancelSendingPieceEvent, event);
|
||||
}
|
||||
|
||||
// Cancel sending piece message to peer.
|
||||
|
@ -168,9 +169,8 @@ void DefaultBtMessageDispatcher::doAbortOutstandingRequestAction(const PieceHand
|
|||
BtAbortOutstandingRequestEvent event(piece);
|
||||
|
||||
BtMessages tempQueue = messageQueue;
|
||||
std::for_each(tempQueue.begin(), tempQueue.end(),
|
||||
std::bind2nd(mem_fun_sh(&BtMessage::onAbortOutstandingRequestEvent),
|
||||
event));
|
||||
forEachMemFunSH(tempQueue.begin(), tempQueue.end(),
|
||||
&BtMessage::onAbortOutstandingRequestEvent, event);
|
||||
}
|
||||
|
||||
class ProcessChokedRequestSlot {
|
||||
|
@ -233,8 +233,8 @@ void DefaultBtMessageDispatcher::doChokingAction()
|
|||
BtChokingEvent event;
|
||||
|
||||
BtMessages tempQueue = messageQueue;
|
||||
std::for_each(tempQueue.begin(), tempQueue.end(),
|
||||
std::bind2nd(mem_fun_sh(&BtMessage::onChokingEvent), event));
|
||||
forEachMemFunSH(tempQueue.begin(), tempQueue.end(),
|
||||
&BtMessage::onChokingEvent, event);
|
||||
}
|
||||
|
||||
class ProcessStaleRequestSlot {
|
||||
|
|
10
src/a2algo.h
10
src/a2algo.h
|
@ -84,6 +84,16 @@ std::pair<InputIterator, size_t> max_sequence(InputIterator first,
|
|||
return std::pair<InputIterator, size_t>(maxfirst, maxlen);
|
||||
}
|
||||
|
||||
template<typename InputIterator, typename R, typename C, typename A,
|
||||
typename ACompat>
|
||||
static void forEachMemFunSH(InputIterator first, InputIterator last,
|
||||
R (C::*f)(A), ACompat arg)
|
||||
{
|
||||
for(; first != last; ++first) {
|
||||
((*first).get()->*f)(arg);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace aria2
|
||||
|
||||
#endif // _D_A2_ALGO_H_
|
||||
|
|
Loading…
Reference in New Issue