本文整理汇总了C++中ACE_Pipe类的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Pipe类的具体用法?C++ ACE_Pipe怎么用?C++ ACE_Pipe使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ACE_Pipe类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup_unnamed_pipe
static int
setup_unnamed_pipe (ACE_Process_Options &opt)
{
// Create an unnamed pipe instance.
ACE_Pipe pipe;
// Check if the pipe is created successfully.
if (pipe.open () == -1)
ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "pipe.open"), -1);
// Setting up pipe between parent and child process. Use the pipe
// as child process'es ACE_STDIN. ACE_Process_Options will keep
// copies (by dup) of fd's that we pass in. Notice that we have to
// specify child process to use ACE_STDOUT for output explicitly
// because we'll close it down in the line after. Child process
// will use whatever we use to dup2 ACE_STDOUT as its stdout.
opt.set_handles (pipe.read_handle (), ACE_STDOUT);
// The previous keep a copy of original ACE_STDOUT fd, now we
// can replace ACE_STDOUT of parent process to the pipe.
ACE_OS::dup2 (pipe.write_handle (), ACE_STDOUT);
// Don't forget to close the unused fd.
pipe.close ();
return 0;
}
示例2: ACE_TMAIN
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
if (argc != 2)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("usage: pingpong <string>\n")),
-1);
ACE_LOG_MSG->open (argv[0]);
string_name = argv[1];
ACE_HANDLE handles[2];
//FUZZ: disable check_for_lack_ACE_OS
// Create a pipe and initialize the handles.
ACE_Pipe pipe (handles);
//FUZZ: enable check_for_lack_ACE_OS
#if defined (ACE_WIN32) || defined (CHORUS)
if (ACE_Thread::spawn (ACE_THR_FUNC (worker),
(void *) handles[0],
THR_DETACHED) == -1
|| ACE_Thread::spawn (ACE_THR_FUNC (worker),
(void *) handles[1],
THR_DETACHED) == -1)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n%a"),
ACE_TEXT ("spawn"),
1));
barrier.wait ();
#else
pid_t pid = ACE_OS::fork (argv[0]);
if (pid == -1)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n%a"),
ACE_TEXT ("fork"),
1));
run_svc (handles[pid == 0]);
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) %n: shutting down tester\n")));
#endif /* ACE_WIN32 */
if (pipe.close () == -1)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("close")));
return 0;
}
示例3: open_pipe
static void
open_pipe (ACE_Pipe &pipe,
const char *name)
{
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("opening %C\n"), name));
int result = pipe.open ();
ACE_TEST_ASSERT (result != -1);
result = pipe.read_handle () != ACE_INVALID_HANDLE
&& pipe.write_handle () != ACE_INVALID_HANDLE;
ACE_TEST_ASSERT (result == 1);
if (close_pipe)
pipe.close ();
}
示例4: write_to_pipe
// Write some data to the pipe. This will cause handle_input to get
// called.
void
write_to_pipe (ACE_Pipe &pipe)
{
char *data = "hello";
size_t len = ACE_OS::strlen (data);
ssize_t result = ACE::send (pipe.write_handle (),
data,
len);
ACE_ASSERT ((size_t)result == len);
ACE_UNUSED_ARG (result);
}
示例5:
ACE_HANDLE Socket_Impl::
get_handle_ ()
{
if (signal_pipe_.read_handle () == ACE_INVALID_HANDLE)
{
signal_pipe_.open ();
}
return signal_pipe_.read_handle ();
}
示例6: recv
void Socket_Impl::recv (Message_ptr m)
{
if (m->find (Data::id) != 0 || m->find (NoData::id) != 0)
{
if (!loop_)
{
Address to (static_cast<To const*> (m->find (To::id))->address ());
Address from (
static_cast<From const*> (m->find (From::id))->address ());
if (to == from)
return;
}
Lock l (mutex_);
//if (queue_.size () != 0)
// cerr << "recv socket queue size: " << queue_.size () << endl;
//FUZZ: disable check_for_lack_ACE_OS
bool signal (queue_.is_empty ());
//FUZZ: enable check_for_lack_ACE_OS
queue_.enqueue_tail (m);
if (signal)
{
// Also write to the pipe.
if (signal_pipe_.write_handle () != ACE_INVALID_HANDLE)
{
char c;
if (signal_pipe_.send (&c, 1) != 1)
{
// perror ("write: ");
ACE_OS::abort ();
}
}
cond_.signal ();
}
}
}
示例7: open
int Handler::open(ACE_Reactor * r)
{
if(-1 == the_pipe_.open(handles_))
{
return -1;
}
if(-1 == r->register_handler(this, ACE_Event_Handler::READ_MASK))
{
return -1;
}
return 0;
}
示例8: l
ssize_t Socket_Impl::
recv_ (void* buf,
size_t s,
ACE_Time_Value const* timeout,
ACE_INET_Addr* from)
{
ACE_Time_Value abs_time;
if (timeout)
abs_time = ACE_OS::gettimeofday () + *timeout;
Lock l (mutex_);
while (queue_.is_empty ())
{
if (timeout)
{
if (cond_.wait (&abs_time) != -1)
break;
}
else
{
if (cond_.wait () != -1)
break;
}
return -1; // errno is already set
}
Message_ptr m;
if (queue_.dequeue_head (m) == -1)
ACE_OS::abort ();
if (queue_.is_empty ())
{
// Remove data from the pipe.
//
if (signal_pipe_.read_handle () != ACE_INVALID_HANDLE)
{
char c;
if (signal_pipe_.recv (&c, 1) != 1)
{
ACE_OS::perror ("read: ");
ACE_OS::abort ();
}
}
}
if (from)
*from = static_cast<From const*> (m->find (From::id))->address ();
if (m->find (NoData::id) != 0)
{
errno = ENOENT;
return -1;
}
Data const* d = static_cast<Data const*>(m->find (Data::id));
ssize_t r (static_cast<ssize_t> (d->size () < s ? d->size () : s));
ACE_OS::memcpy (buf, d->buf (), r);
return r;
}
示例9:
ACE_HANDLE
Handler::get_handle() const
{
return the_pipe_.read_handle ();
}
示例10: sizeof
void
Handler::send_dummy_data()
{
char buf[] = "dummy";
(void) the_pipe_.send (buf, sizeof (buf));
}