[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/rtmp r9702: add support for the function p
From: |
rob |
Subject: |
[Gnash-commit] /srv/bzr/gnash/rtmp r9702: add support for the function pointers to go with events on a file descriptor. |
Date: |
Wed, 05 Nov 2008 20:12:35 -0700 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 9702
committer: address@hidden
branch nick: rtmp
timestamp: Wed 2008-11-05 20:12:35 -0700
message:
add support for the function pointers to go with events on a file descriptor.
modified:
libnet/handler.cpp
libnet/handler.h
testsuite/libnet.all/test_handler.cpp
=== modified file 'libnet/handler.cpp'
--- a/libnet/handler.cpp 2008-11-06 02:31:49 +0000
+++ b/libnet/handler.cpp 2008-11-06 03:12:35 +0000
@@ -161,6 +161,14 @@
}
void
+Handler::addPollFD(struct pollfd &fd, Handler::entry_t *func)
+{
+ boost::mutex::scoped_lock lock(_poll_mutex);
+ _handlers[fd.fd] = func;
+ _pollfds.push_back(fd);
+}
+
+void
Handler::addPollFD(struct pollfd &fd)
{
boost::mutex::scoped_lock lock(_poll_mutex);
@@ -180,6 +188,22 @@
return &_pollfds[0];
};
+void
+Handler::addEntry(int fd, Handler::entry_t *func)
+{
+ GNASH_REPORT_FUNCTION;
+ boost::mutex::scoped_lock lock(_poll_mutex);
+ _handlers[fd] = func;
+}
+
+Handler::entry_t *
+Handler::getEntry(int fd)
+{
+ GNASH_REPORT_FUNCTION;
+ boost::mutex::scoped_lock lock(_poll_mutex);
+ return _handlers[fd];
+};
+
// Dump internal data.
void
Handler::dump()
=== modified file 'libnet/handler.h'
--- a/libnet/handler.h 2008-11-06 02:31:49 +0000
+++ b/libnet/handler.h 2008-11-06 03:12:35 +0000
@@ -177,9 +177,15 @@
void die() { _die = true; _outgoing.notify(); };
bool timetodie() { return _die; };
+ void addPollFD(struct pollfd &fd, entry_t *ptr);
void addPollFD(struct pollfd &fd);
struct pollfd &getPollFD(int index);
struct pollfd *getPollFDPtr();
+
+ void addEntry(int fd, entry_t *func);
+ entry_t *getEntry(int fd);
+
+// void executePollFD(int index) { _handler[index](); ];
private:
bool _die;
=== modified file 'testsuite/libnet.all/test_handler.cpp'
--- a/testsuite/libnet.all/test_handler.cpp 2008-11-06 02:30:34 +0000
+++ b/testsuite/libnet.all/test_handler.cpp 2008-11-06 03:12:35 +0000
@@ -67,11 +67,15 @@
TestState runtest;
LogFile& dbglogfile = LogFile::getDefaultInstance();
static bool dump = false;
+static const char *result;
static void usage (void);
static void test_pollfds();
static void test_que();
+void test1(Handler::thread_params_t *args);
+void test2(Handler::thread_params_t *args);
+
int
main (int argc, char* argv[]) {
const Arg_parser::Option opts[] =
@@ -121,21 +125,23 @@
{
Handler hand;
struct pollfd fds1;
+ Handler::entry_t *func1 = test1;
fds1.fd = 3;
fds1.events = POLLIN | POLLRDHUP;
- hand.addPollFD(fds1);
- if (hand.getPollFD(0).fd == 3) {
+ hand.addPollFD(fds1, test1);
+ if ((hand.getPollFD(0).fd == 3) && (hand.getEntry(3) == func1)) {
runtest.pass ("Handler::addPollFD(0)");
} else {
runtest.fail ("Handler::addPollFD(0)");
}
struct pollfd fds2;
+ Handler::entry_t *func2 = test2;
fds2.fd = 4;
fds2.events = POLLIN | POLLRDHUP;
- hand.addPollFD(fds2);
+ hand.addPollFD(fds2, test2);
if (hand.getPollFD(1).fd == 4) {
runtest.pass ("Handler::addPollFD(1)");
} else {
@@ -148,6 +154,32 @@
} else {
runtest.fail ("Handler::getPollFDPtr()");
}
+
+ Handler::thread_params_t args;
+ Handler::entry_t *ptr1 = hand.getEntry(3);
+ if (ptr1) {
+ ptr1(&args);
+ if (strcmp(result, "test1") == 0) {
+ runtest.pass ("test1()");
+ } else {
+ runtest.fail ("test1()");
+ }
+ } else {
+ runtest.unresolved ("test1()");
+ }
+
+ Handler::entry_t *ptr2 = hand.getEntry(4);
+ if (ptr2) {
+ ptr2(&args);
+ if (strcmp(result, "test2") == 0) {
+ runtest.pass ("test2()");
+ } else {
+ runtest.fail ("test2()");
+ }
+ } else {
+ runtest.unresolved ("test2()");
+ }
+
}
void
@@ -221,6 +253,19 @@
// que.dump();
}
+void
+test1(Handler::thread_params_t *args)
+{
+ result = "test1";
+}
+
+void
+test2(Handler::thread_params_t *args)
+{
+ result = "test2";
+}
+
+
static void
usage (void)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/rtmp r9702: add support for the function pointers to go with events on a file descriptor.,
rob <=