aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-04-12 15:38:02 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-04-20 16:42:37 +0100
commit43bfea0710c66113543305cfa2181dacf8df3df2 (patch)
tree91bb8aeba6c6f1fca4e8a2c3cf967c7705985d10
parent360d337e8a866cf108498a67f089119cd2789d2c (diff)
downloadpaludis-43bfea0710c66113543305cfa2181dacf8df3df2.tar.gz
paludis-43bfea0710c66113543305cfa2181dacf8df3df2.tar.xz
Callback for IPCInputManager creation
-rw-r--r--paludis/ipc_output_manager.cc14
-rw-r--r--paludis/ipc_output_manager.hh3
-rw-r--r--src/clients/cave/cmd_execute_resolution.cc12
3 files changed, 20 insertions, 9 deletions
diff --git a/paludis/ipc_output_manager.cc b/paludis/ipc_output_manager.cc
index 4880b37..ea29f21 100644
--- a/paludis/ipc_output_manager.cc
+++ b/paludis/ipc_output_manager.cc
@@ -182,6 +182,7 @@ namespace paludis
{
const Environment * const env;
const OutputExclusivity exclusivity;
+ const std::tr1::function<void (const std::tr1::shared_ptr<OutputManager> &)> on_create;
mutable Mutex mutex;
std::tr1::shared_ptr<OutputManager> output_manager;
@@ -189,9 +190,11 @@ namespace paludis
Pipe stdout_pipe, stderr_pipe, finished_pipe;
- Implementation(const Environment * const e, const OutputExclusivity x) :
+ Implementation(const Environment * const e, const OutputExclusivity x,
+ const std::tr1::function<void (const std::tr1::shared_ptr<OutputManager> &)> & c) :
env(e),
- exclusivity(x)
+ exclusivity(x),
+ on_create(c)
{
if (0 != ::fcntl(finished_pipe.read_fd(), F_SETFD, FD_CLOEXEC))
throw InternalError(PALUDIS_HERE, "fcntl failed");
@@ -205,8 +208,9 @@ namespace paludis
};
}
-IPCInputManager::IPCInputManager(const Environment * const e, const OutputExclusivity x) :
- PrivateImplementationPattern<IPCInputManager>(new Implementation<IPCInputManager>(e, x))
+IPCInputManager::IPCInputManager(const Environment * const e, const OutputExclusivity x,
+ const std::tr1::function<void (const std::tr1::shared_ptr<OutputManager> &)> & c) :
+ PrivateImplementationPattern<IPCInputManager>(new Implementation<IPCInputManager>(e, x, c))
{
}
@@ -254,6 +258,8 @@ IPCInputManager::_pipe_command_handler(const std::string & s)
return "Ealready constructed";
_imp->output_manager = _imp->env->create_output_manager(*i);
+ if (_imp->on_create)
+ _imp->on_create(_imp->output_manager);
}
_imp->copy_thread.reset(new Thread(std::tr1::bind(&IPCInputManager::_copy_thread, this)));
diff --git a/paludis/ipc_output_manager.hh b/paludis/ipc_output_manager.hh
index f3ff59f..d02128f 100644
--- a/paludis/ipc_output_manager.hh
+++ b/paludis/ipc_output_manager.hh
@@ -65,7 +65,8 @@ namespace paludis
public:
IPCInputManager(
const Environment * const,
- const OutputExclusivity);
+ const OutputExclusivity,
+ const std::tr1::function<void (const std::tr1::shared_ptr<OutputManager> &)> &);
~IPCInputManager();
diff --git a/src/clients/cave/cmd_execute_resolution.cc b/src/clients/cave/cmd_execute_resolution.cc
index 8244060..1b5c59c 100644
--- a/src/clients/cave/cmd_execute_resolution.cc
+++ b/src/clients/cave/cmd_execute_resolution.cc
@@ -169,7 +169,8 @@ namespace
a != a_end ; ++a)
command = command + " " + args::escape(*a);
- IPCInputManager input_manager(env.get(), oe_exclusive);
+ IPCInputManager input_manager(env.get(), oe_exclusive,
+ std::tr1::function<void (const std::tr1::shared_ptr<OutputManager> &)>());
paludis::Command cmd(command);
cmd
.with_pipe_command_handler("PALUDIS_IPC", input_manager.pipe_command_handler())
@@ -250,7 +251,8 @@ namespace
command.append(" --" + cmdline.import_options.a_unpackaged_repository_params.long_name() + " '" + *p + "'");
}
- IPCInputManager input_manager(env.get(), oe_exclusive);
+ IPCInputManager input_manager(env.get(), oe_exclusive,
+ std::tr1::function<void (const std::tr1::shared_ptr<OutputManager> &)>());
paludis::Command cmd(command);
cmd
.with_pipe_command_handler("PALUDIS_IPC", input_manager.pipe_command_handler())
@@ -351,7 +353,8 @@ namespace
command.append(" --" + cmdline.import_options.a_unpackaged_repository_params.long_name() + " '" + *p + "'");
}
- IPCInputManager input_manager(env.get(), oe_exclusive);
+ IPCInputManager input_manager(env.get(), oe_exclusive,
+ std::tr1::function<void (const std::tr1::shared_ptr<OutputManager> &)>());
paludis::Command cmd(command);
cmd
.with_pipe_command_handler("PALUDIS_IPC", input_manager.pipe_command_handler())
@@ -425,7 +428,8 @@ namespace
command.append(" --" + cmdline.import_options.a_unpackaged_repository_params.long_name() + " '" + *p + "'");
}
- IPCInputManager input_manager(env.get(), oe_exclusive);
+ IPCInputManager input_manager(env.get(), oe_exclusive,
+ std::tr1::function<void (const std::tr1::shared_ptr<OutputManager> &)>());
paludis::Command cmd(command);
cmd
.with_pipe_command_handler("PALUDIS_IPC", input_manager.pipe_command_handler())