Merge lp:~eday/scalestack/style-updates into lp:~registry/scalestack/old-trunk

Proposed by Eric Day
Status: Merged
Merged at revision: 59
Proposed branch: lp:~eday/scalestack/style-updates
Merge into: lp:~registry/scalestack/old-trunk
Diff against target: 3712 lines (+1144/-624)
60 files modified
Makefile.am (+3/-3)
README (+9/-9)
bin/scalestack.cc (+4/-2)
scalestack/common/delete_pointer.h (+4/-1)
scalestack/common/exception.h (+2/-1)
scalestack/common/macros.h.in (+4/-0)
scalestack/common/notification.cc (+1/-1)
scalestack/common/notification.h (+2/-1)
scalestack/common/test.h (+30/-2)
scalestack/event/handler.h (+19/-19)
scalestack/event/handler_service.h (+119/-45)
scalestack/event/libevent/handler_provider.cc (+12/-5)
scalestack/event/libevent/handler_provider.h (+16/-6)
scalestack/event/libevent/handler_service_provider.cc (+118/-52)
scalestack/event/libevent/handler_service_provider.h (+44/-43)
scalestack/event/libevent/libevent.cc (+13/-13)
scalestack/event/libevent/plugin.ini (+2/-2)
scalestack/event/libevent/service.cc (+37/-30)
scalestack/event/libevent/service.h (+35/-15)
scalestack/event/libevent/thread.cc (+78/-30)
scalestack/event/libevent/thread.h (+14/-10)
scalestack/event/plugin.ini (+2/-2)
scalestack/event/service.h (+95/-0)
scalestack/event/test/handler.cc (+2/-2)
scalestack/event/test/handler.h (+1/-1)
scalestack/event/test/handler_provider.cc (+4/-4)
scalestack/event/test/handler_provider.h (+3/-3)
scalestack/event/test/handler_service.cc (+6/-6)
scalestack/event/test/handler_service.h (+11/-11)
scalestack/event/test/handler_service_provider.cc (+27/-27)
scalestack/event/test/handler_service_provider.h (+23/-22)
scalestack/event/test/plugin.ini (+2/-2)
scalestack/event/test/run.cc (+0/-1)
scalestack/event/test/service.cc (+57/-0)
scalestack/event/test/service.h (+66/-0)
scalestack/event/test/test.cc (+23/-27)
scalestack/kernel/core.cc (+75/-79)
scalestack/kernel/core.h (+20/-19)
scalestack/kernel/log.h (+3/-3)
scalestack/kernel/log_console.h (+3/-1)
scalestack/kernel/log_message.h (+21/-9)
scalestack/kernel/module.cc (+36/-36)
scalestack/kernel/module.h (+17/-11)
scalestack/kernel/option.cc (+2/-2)
scalestack/kernel/option.h (+4/-4)
scalestack/kernel/service.h (+5/-5)
scalestack/kernel/test/module.cc (+12/-3)
scalestack/kernel/test/option.cc (+4/-1)
scalestack/network/datagram.cc (+2/-2)
scalestack/network/datagram.h (+5/-5)
scalestack/network/datagram_service.h (+5/-5)
scalestack/network/ip/tcp/listener_service.cc (+7/-7)
scalestack/network/ip/tcp/listener_service.h (+4/-4)
scalestack/network/listener.cc (+5/-5)
scalestack/network/listener.h (+5/-4)
scalestack/network/local/stream/listener_service.cc (+5/-5)
scalestack/network/local/stream/listener_service.h (+4/-4)
scalestack/network/stream.cc (+2/-2)
scalestack/network/stream.h (+5/-5)
scalestack/network/stream_service.h (+5/-5)
To merge this branch: bzr merge lp:~eday/scalestack/style-updates
Reviewer Review Type Date Requested Status
Registry Administrators Pending
Review via email: mp+27584@code.launchpad.net

Description of the change

Minor style issues to make things a bit more consistent. I'll be going through the other modules as well making the same kinds of tweaks.

To post a comment you must log in.
lp:~eday/scalestack/style-updates updated
60. By Eric Day

Reworked event interface to push more logic into the providers, updated coding style around those changes, and tweaked a few documentation settings.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile.am'
2--- Makefile.am 2010-06-03 04:51:37 +0000
3+++ Makefile.am 2010-06-16 19:32:28 +0000
4@@ -112,9 +112,9 @@
5 docs: all
6 @echo "/**" > docs/mainpage.h
7 @echo "@mainpage README" >> docs/mainpage.h
8- @echo "<pre>" >> docs/mainpage.h
9- @cat ${top_srcdir}/README >> docs/mainpage.h
10- @echo "</pre>" >> docs/mainpage.h
11+ @echo "<pre>@htmlonly" >> docs/mainpage.h
12+ @cat ${top_srcdir}/README | sed 's/\(http[^ ]*\)/<a href="\1">\1<\/a>/' >> docs/mainpage.h
13+ @echo "@endhtmlonly</pre>" >> docs/mainpage.h
14 @echo "*/" >> docs/mainpage.h
15 ${DOXYGEN} ${top_srcdir}/docs/doxyfile
16 @rm docs/mainpage.h
17
18=== modified file 'README'
19--- README 2010-06-03 04:51:37 +0000
20+++ README 2010-06-16 19:32:28 +0000
21@@ -104,38 +104,38 @@
22
23 Exceptions to this guide include:
24
25-* Comments should follow Doxygen style formatting. See existing code
26+- Comments should follow Doxygen style formatting. See existing code
27 for examples.
28
29-* Opening curly braces should appear on their own line.
30+- Opening curly braces should appear on their own line.
31
32-* C++ exceptions are allowed if they derive from std::exception. Most
33+- C++ exceptions are allowed if they derive from std::exception. Most
34 exception throwing is hidden behind log_fatal messages, which throw
35 scalestack::common::exception and contains custom messages. Use of
36 this through module.log_fatal() in modules is preferred.
37
38-* All namespaces, classes, methods, and data members must be all
39+- All namespaces, classes, methods, and data members must be all
40 lowercase and use '_' to separate words (like the C++ STL).
41
42-* Private method names should start with an underscore.
43+- Private method names should start with an underscore.
44
45-* Data members should always be private and start with an underscore.
46+- Data members should always be private and start with an underscore.
47 The leading underscores help to easily differentiate the class
48 members from local method variables. Some data members may be under
49 the protected section so derived classes can also access them.
50
51-* Header files should be ordered by system and then Scale Stack
52+- Header files should be ordered by system and then Scale Stack
53 headers, with a empty line in between. Each set should be ordered
54 alphabetically as well. The "config.h" include must be the first
55 include for every non-header file, and should NEVER appear in any
56 header files.
57
58-* You should only use 'using namespace ...;' in source files, never in
59+- You should only use 'using namespace ...;' in source files, never in
60 header files. In source files, only specify 'using namespace std;'
61 and 'using namespace scalestack;'. Beyond that, please write out
62 the full namespace for objects.
63
64-* In general, do the most consistent thing given the existing code
65+- In general, do the most consistent thing given the existing code
66 base. If something is not immediately obvious, is ambiguous, or
67 if you feel is wrong, please bring it up on the mailing list or in
68 IRC so we can clarify it and improve this document. :)
69
70=== modified file 'bin/scalestack.cc'
71--- bin/scalestack.cc 2010-06-03 04:51:37 +0000
72+++ bin/scalestack.cc 2010-06-16 19:32:28 +0000
73@@ -18,6 +18,8 @@
74
75 #include <scalestack/kernel/core.h>
76
77+using namespace std;
78+
79 int main(int argc, const char* argv[])
80 {
81 scalestack::kernel::core core;
82@@ -33,9 +35,9 @@
83 core.set_signal_handlers();
84 core.run();
85 }
86- catch (std::exception& e)
87+ catch (exception& e)
88 {
89- std::cout << e.what() << std::endl;
90+ cout << e.what() << endl;
91 return 1;
92 }
93
94
95=== modified file 'scalestack/common/delete_pointer.h'
96--- scalestack/common/delete_pointer.h 2010-06-03 04:51:37 +0000
97+++ scalestack/common/delete_pointer.h 2010-06-16 19:32:28 +0000
98@@ -10,7 +10,7 @@
99
100 /**
101 * @file
102- * @brief Delete Pointer Function Object Declaration
103+ * @brief Delete Pointer Function Object
104 */
105
106 #ifndef SCALESTACK_COMMON_DELETE_POINTER_H
107@@ -29,6 +29,9 @@
108 {
109 public:
110
111+ /**
112+ * Delete the pointer passed in as an argument.
113+ */
114 template<typename T>
115 void operator()(const T* pointer) const
116 {
117
118=== modified file 'scalestack/common/exception.h'
119--- scalestack/common/exception.h 2010-06-03 04:51:37 +0000
120+++ scalestack/common/exception.h 2010-06-16 19:32:28 +0000
121@@ -26,7 +26,8 @@
122 {
123
124 /**
125- * This class allows exceptions to be thrown with custom error mesages.
126+ * This class allows exceptions to be thrown with custom error mesages
127+ * without the possiblity of throwing any exceptions itself.
128 */
129 class SCALESTACK_API exception: public std::exception
130 {
131
132=== modified file 'scalestack/common/macros.h.in'
133--- scalestack/common/macros.h.in 2010-06-03 04:51:37 +0000
134+++ scalestack/common/macros.h.in 2010-06-16 19:32:28 +0000
135@@ -70,6 +70,10 @@
136 */
137 #define SCALESTACK_MAX_MESSAGE_SIZE 1024
138
139+/**
140+ * Macro to use around strings that should be translated in preparation for
141+ * using gettext.
142+ */
143 #define _(string) string
144
145 #endif /* SCALESTACK_COMMON_MACROS_H */
146
147=== modified file 'scalestack/common/notification.cc'
148--- scalestack/common/notification.cc 2010-06-03 04:51:37 +0000
149+++ scalestack/common/notification.cc 2010-06-16 19:32:28 +0000
150@@ -66,7 +66,7 @@
151 {
152 char message[SCALESTACK_MAX_MESSAGE_SIZE];
153 snprintf(message, SCALESTACK_MAX_MESSAGE_SIZE,
154- "%s: %s", prefix, strerror(errno));
155+ "%s: %s:%d", prefix, strerror(errno), errno);
156 throw exception("notification", message);
157 }
158
159
160=== modified file 'scalestack/common/notification.h'
161--- scalestack/common/notification.h 2010-06-03 04:51:37 +0000
162+++ scalestack/common/notification.h 2010-06-16 19:32:28 +0000
163@@ -24,7 +24,8 @@
164 {
165
166 /**
167- * This class provides a way for different threads to notify each other.
168+ * This class provides a way for different threads to notify each other. This
169+ * uses a pipe rather than conditional thread mechanisms to be more portable.
170 */
171 class SCALESTACK_API notification
172 {
173
174=== modified file 'scalestack/common/test.h'
175--- scalestack/common/test.h 2010-06-03 04:51:37 +0000
176+++ scalestack/common/test.h 2010-06-16 19:32:28 +0000
177@@ -28,8 +28,15 @@
178 using namespace std;
179 using namespace scalestack;
180
181+/**
182+ * Default event service to use.
183+ */
184 #define TEST_EVENT_SERVICE "event::libevent"
185
186+/**
187+ * Begin a test suite block, there should only be one of these per source
188+ * file.
189+ */
190 #define TEST_SUITE_BEGIN \
191 int main(int _test_argc, char* _test_argv[]) \
192 { \
193@@ -39,33 +46,51 @@
194 if (TEST_LOG_THRESHOLD > 0) \
195 cout << endl << __FILE__ << endl;
196
197+/**
198+ * Finish the test suite block.
199+ */
200 #define TEST_SUITE_END \
201 return 0; \
202 }
203
204+/**
205+ * Begin a test block without defining a kernel core object.
206+ */
207 #define TEST_BEGIN_NO_CORE(name) \
208 if (TEST_LOG_THRESHOLD > 0) \
209 cout << "---------- TESTING " << #name << endl; \
210 {
211
212+/**
213+ * Begin a test block with a default kernel core object named 'core'.
214+ */
215 #define TEST_BEGIN(name) \
216 TEST_BEGIN_NO_CORE(name) \
217 kernel::core core; \
218- core.set_log_threshold(TEST_LOG_THRESHOLD); \
219+ core.set_threshold(TEST_LOG_THRESHOLD); \
220 core.add_module_option_value("path", "", "scalestack/.libs");
221
222-
223+/**
224+ * End a test block.
225+ */
226 #define TEST_END \
227 } \
228 if (TEST_LOG_THRESHOLD > 0) \
229 cout << "---------- PASSED" << endl << endl;
230
231+/**
232+ * Begin an exception test block. This tests to make sure an exception
233+ * is thrown.
234+ */
235 #define TEST_EXCEPTION_BEGIN \
236 { \
237 bool _test_exception = false; \
238 try \
239 {
240
241+/**
242+ * End an exception test block.
243+ */
244 #define TEST_EXCEPTION_END \
245 } \
246 catch (exception&) \
247@@ -75,6 +100,9 @@
248 assert(_test_exception); \
249 }
250
251+/**
252+ * Test a single line of code to make sure it throws an exception.
253+ */
254 #define TEST_EXCEPTION(code) \
255 do \
256 TEST_EXCEPTION_BEGIN \
257
258=== modified file 'scalestack/event/handler.h'
259--- scalestack/event/handler.h 2010-06-03 04:51:37 +0000
260+++ scalestack/event/handler.h 2010-06-16 19:32:28 +0000
261@@ -19,7 +19,7 @@
262 #include <ctime>
263
264 #include <scalestack/common/macros.h>
265-#include <scalestack/event/service.h>
266+#include <scalestack/event/handler_service.h>
267
268 namespace scalestack
269 {
270@@ -34,18 +34,16 @@
271 */
272 class SCALESTACK_API handler
273 {
274- friend class handler_provider;
275-
276 public:
277
278- handler(service& creator);
279+ handler(handler_service& handler_service);
280
281 virtual ~handler();
282
283 /**
284- * Get the service this handler belongs to.
285+ * Get the handler service this handler belongs to.
286 */
287- service& get_service(void);
288+ handler_service& get_handler_service(void);
289
290 /**
291 * This method is run after the event service has added it.
292@@ -116,7 +114,7 @@
293
294 protected:
295
296- service& _service;
297+ handler_service& _handler_service;
298 kernel::module& _module;
299
300 private:
301@@ -134,6 +132,8 @@
302 handler& operator=(const handler&);
303
304 handler_provider* _handler_provider;
305+
306+ friend class handler_provider;
307 };
308
309 /**
310@@ -156,13 +156,13 @@
311
312 /**
313 * Set the handler for this handler_provider. This is used while
314- * initializing the event handler in the service class. This is required
315- * in order to reuse both handler and handler_provider instances, which
316- * will be implemented by unrelated classes.
317+ * initializing the event handler in the handler service class. This is
318+ * required in order to reuse both handler and handler_provider instances,
319+ * which will be implemented by unrelated classes.
320 *
321- * @param[in] bound_handler Handler to bind to this provider.
322+ * @param[in] handler Handler to bind to this provider.
323 */
324- void set_handler(handler* bound_handler);
325+ void set_handler(handler* handler);
326
327 /**
328 * See handler::start().
329@@ -245,9 +245,9 @@
330 * Public handler methods.
331 */
332
333-inline handler::handler(service& creator):
334- _service(creator),
335- _module(creator.get_module()),
336+inline handler::handler(handler_service& handler_service):
337+ _handler_service(handler_service),
338+ _module(handler_service.get_module()),
339 _handler_provider(NULL)
340 {
341 }
342@@ -256,9 +256,9 @@
343 {
344 }
345
346-inline service& handler::get_service(void)
347+inline handler_service& handler::get_handler_service(void)
348 {
349- return _service;
350+ return _handler_service;
351 }
352
353 inline void handler::start(void)
354@@ -334,9 +334,9 @@
355 return _handler;
356 }
357
358-inline void handler_provider::set_handler(handler* bound_handler)
359+inline void handler_provider::set_handler(handler* handler)
360 {
361- _handler = bound_handler;
362+ _handler = handler;
363 _handler->_handler_provider = this;
364 }
365
366
367=== renamed file 'scalestack/event/service.h' => 'scalestack/event/handler_service.h'
368--- scalestack/event/service.h 2010-06-03 20:51:05 +0000
369+++ scalestack/event/handler_service.h 2010-06-16 19:32:28 +0000
370@@ -10,17 +10,16 @@
371
372 /**
373 * @file
374- * @brief Event Service Declarations
375+ * @brief Event Handler Service and Handler Service Provider Declarations
376 */
377
378-#ifndef SCALESTACK_EVENT_SERVICE_H
379-#define SCALESTACK_EVENT_SERVICE_H
380-
381-#include <pthread.h>
382-#include <set>
383+#ifndef SCALESTACK_EVENT_HANDLER_SERVICE_H
384+#define SCALESTACK_EVENT_HANDLER_SERVICE_H
385
386 #include <scalestack/common/macros.h>
387-#include <scalestack/common/notification.h>
388+#include <scalestack/event/service.h>
389+#include <scalestack/kernel/core.h>
390+#include <scalestack/kernel/module.h>
391 #include <scalestack/kernel/service.h>
392
393 namespace scalestack
394@@ -29,46 +28,44 @@
395 {
396
397 class handler;
398-class service_provider;
399+class handler_service_provider;
400
401 /**
402 * This is a base class that other classes using handler classes must
403 * implement. This provides a way to add and remove event handlers from the
404 * event service provider.
405 */
406-class SCALESTACK_API service: public kernel::service
407+class SCALESTACK_API handler_service: public kernel::service
408 {
409- friend class service_provider;
410-
411 public:
412
413 /**
414- * Constructor for event service provider.
415+ * Constructor for event handler service.
416 *
417- * @param[in] creator Module that the service is associated with.
418+ * @param[in] module Module that the handler service is associated with.
419 */
420- service(kernel::module& creator);
421+ handler_service(kernel::module& module);
422
423- virtual ~service();
424+ virtual ~handler_service();
425
426 /**
427- * Add an event handler to one of the event service threads.
428+ * Add an event handler to the handler service.
429 *
430- * @param[in] new_handler Event handler to add.
431+ * @param[in] handler Event handler to add.
432 */
433- void add_handler(handler* new_handler);
434+ void add_handler(handler* handler);
435
436 /**
437 * Remove an event handler. This is called by the event service when the
438 * handler is no longer in use.
439 *
440- * @param[in] old_handler Event handler to remove.
441+ * @param[in] handler Event handler to remove.
442 */
443- virtual void remove_handler(handler* old_handler) = 0;
444+ virtual void remove_handler(handler* handler) = 0;
445
446 /**
447- * Shutdown the service by removing all associated handlers. This can
448- * block and should most likely only be used during shutdown in derived
449+ * Shutdown the handler service by removing all associated handlers. This
450+ * can block and should most likely only be used during shutdown in derived
451 * class destructors.
452 */
453 void shutdown(void);
454@@ -79,30 +76,107 @@
455 * Don't allow copying of objects.
456 */
457 SCALESTACK_LOCAL
458- service(const service&);
459-
460- /**
461- * Don't allow assignment of objects.
462- */
463- SCALESTACK_LOCAL
464- service& operator=(const service&);
465-
466- /**
467- * Remove a handler from the service and call remove_handler().
468- *
469- * @param[in] old_handler Event handler to remove.
470- */
471- void _remove_handler(handler* old_handler);
472-
473- bool _shutdown;
474- size_t _handler_count;
475- service_provider& _service_provider;
476- pthread_mutex_t _handler_mutex;
477- common::notification _shutdown_notification;
478- std::set<handler*> _handlers;
479-};
480+ handler_service(const handler_service&);
481+
482+ /**
483+ * Don't allow assignment of objects.
484+ */
485+ SCALESTACK_LOCAL
486+ handler_service& operator=(const handler_service&);
487+
488+ handler_service_provider& _handler_service_provider;
489+};
490+
491+/**
492+ * This is a base class that event service provider modules must
493+ * implement. This is used to provide functionality for handler services.
494+ */
495+class SCALESTACK_API handler_service_provider: public kernel::service
496+{
497+public:
498+
499+ handler_service_provider(kernel::module& module,
500+ handler_service& handler_service);
501+
502+ virtual ~handler_service_provider();
503+
504+ /**
505+ * See handler_service::add_handler().
506+ */
507+ virtual void add_handler(handler* handler) = 0;
508+
509+ /**
510+ * See handler_service::remove_handler().
511+ */
512+ virtual void remove_handler(handler* handler);
513+
514+ /**
515+ * See handler_service::add_handler().
516+ */
517+ virtual void shutdown(void) = 0;
518+
519+private:
520+
521+ /**
522+ * Don't allow copying of objects.
523+ */
524+ SCALESTACK_LOCAL
525+ handler_service_provider(const handler_service_provider&);
526+
527+ /**
528+ * Don't allow assignment of objects.
529+ */
530+ SCALESTACK_LOCAL
531+ handler_service_provider& operator=(const handler_service_provider&);
532+
533+ handler_service& _handler_service;
534+};
535+
536+/*
537+ * Public handler_service methods.
538+ */
539+
540+inline handler_service::handler_service(kernel::module& module):
541+ kernel::service(module),
542+ _handler_service_provider(static_cast<event::service&>(module.get_core().get_service("event"))._add_handler_service(*this))
543+{
544+}
545+
546+inline handler_service::~handler_service()
547+{
548+ static_cast<event::service&>(_module.get_core().get_service("event"))._remove_handler_service(_handler_service_provider);
549+}
550+
551+inline void handler_service::add_handler(handler* handler)
552+{
553+ _handler_service_provider.add_handler(handler);
554+}
555+
556+inline void handler_service::shutdown(void)
557+{
558+ _handler_service_provider.shutdown();
559+}
560+
561+/*
562+ * Public handler_service_provider methods.
563+ */
564+
565+inline handler_service_provider::handler_service_provider(kernel::module& module, handler_service& handler_service):
566+ kernel::service(module),
567+ _handler_service(handler_service)
568+{
569+}
570+
571+inline handler_service_provider::~handler_service_provider()
572+{
573+}
574+
575+inline void handler_service_provider::remove_handler(handler* handler)
576+{
577+ _handler_service.remove_handler(handler);
578+}
579
580 } /* namespace event */
581 } /* namespace scalestack */
582
583-#endif /* SCALESTACK_EVENT_SERVICE_H */
584+#endif /* SCALESTACK_EVENT_HANDLER_SERVICE_H */
585
586=== modified file 'scalestack/event/libevent/handler_provider.cc'
587--- scalestack/event/libevent/handler_provider.cc 2010-06-03 04:51:37 +0000
588+++ scalestack/event/libevent/handler_provider.cc 2010-06-16 19:32:28 +0000
589@@ -36,18 +36,19 @@
590 * Public functions.
591 */
592
593-extern "C" void handler_provider_callback(int file_descriptor, short events,
594- void* context)
595+extern "C" void handler_provider_callback(int file_descriptor,
596+ short events,
597+ void* context)
598 {
599- handler_provider* new_handler_provider = static_cast<handler_provider*>(context);
600- new_handler_provider->_callback(file_descriptor, events);
601+ handler_provider* handler_provider = static_cast<libevent::handler_provider*>(context);
602+ handler_provider->_callback(file_descriptor, events);
603 }
604
605 /*
606 * Public methods.
607 */
608
609-handler_provider::handler_provider(kernel::module& module):
610+handler_provider::handler_provider(kernel::module& module, handler_service_provider& handler_service_provider):
611 _in_check_queue(false),
612 _need_start(false),
613 _need_update(false),
614@@ -65,12 +66,18 @@
615 _expire_time(0),
616 _set_expire_time(0),
617 _module(module),
618+ _handler_service_provider(handler_service_provider),
619 _thread(NULL),
620 _event(),
621 _timer()
622 {
623 }
624
625+handler_service_provider& handler_provider::get_handler_service_provider(void)
626+{
627+ return _handler_service_provider;
628+}
629+
630 handler_provider::~handler_provider()
631 {
632 set_thread(NULL);
633
634=== modified file 'scalestack/event/libevent/handler_provider.h'
635--- scalestack/event/libevent/handler_provider.h 2010-06-03 04:51:37 +0000
636+++ scalestack/event/libevent/handler_provider.h 2010-06-16 19:32:28 +0000
637@@ -40,29 +40,34 @@
638 /**
639 * Function passed to libevent to invoke handler_provider::_callback().
640 */
641-extern "C" void handler_provider_callback(int file_descriptor, short events,
642+extern "C" void handler_provider_callback(int file_descriptor,
643+ short events,
644 void* context);
645
646 /**
647- * This is the Handler_provider implementation using libevent.
648+ * This is the event handler provider implementation for libevent.
649 */
650 class SCALESTACK_API handler_provider: public event::handler_provider
651 {
652- friend void handler_provider_callback(int file_descriptor, short events,
653- void* context);
654-
655 public:
656
657 /**
658 * Constructor for handler provider.
659 *
660 * @param[in] module Module that the handler is associated with.
661+ * @param[in] handler_service_provider Owner of this handler provider.
662 */
663- handler_provider(kernel::module& module);
664+ handler_provider(kernel::module& module,
665+ handler_service_provider& handler_service_provider);
666
667 ~handler_provider();
668
669 /**
670+ * Get the handler service provider this handler provider belongs to.
671+ */
672+ handler_service_provider& get_handler_service_provider(void);
673+
674+ /**
675 * Set the thread this handler provider belongs to.
676 *
677 * @param[in] thread Thread to set.
678@@ -167,9 +172,14 @@
679 time_t _expire_time;
680 time_t _set_expire_time;
681 kernel::module& _module;
682+ handler_service_provider& _handler_service_provider;
683 thread* _thread;
684 struct event _event;
685 struct timeval _timer;
686+
687+ friend void handler_provider_callback(int file_descriptor,
688+ short events,
689+ void* context);
690 };
691
692 } /* namespace libevent */
693
694=== renamed file 'scalestack/event/service.cc' => 'scalestack/event/libevent/handler_service_provider.cc'
695--- scalestack/event/service.cc 2010-06-03 04:51:37 +0000
696+++ scalestack/event/libevent/handler_service_provider.cc 2010-06-16 19:32:28 +0000
697@@ -10,7 +10,7 @@
698
699 /**
700 * @file
701- * @brief Event Service Definitions
702+ * @brief libevent Event Handler Service Provider Definitions
703 */
704
705 #include "config.h"
706@@ -21,8 +21,8 @@
707 #include <functional>
708
709 #include <scalestack/event/handler.h>
710-#include <scalestack/event/service.h>
711-#include <scalestack/event/service_provider.h>
712+#include <scalestack/event/libevent/handler_service_provider.h>
713+#include <scalestack/event/libevent/service.h>
714 #include <scalestack/kernel/core.h>
715 #include <scalestack/kernel/module.h>
716
717@@ -32,94 +32,160 @@
718 {
719 namespace event
720 {
721+namespace libevent
722+{
723
724 /*
725 * Public methods.
726 */
727
728-service::service(kernel::module& creator):
729- kernel::service(creator),
730+handler_service_provider::handler_service_provider(kernel::module& module, event::handler_service& handler_service):
731+ event::handler_service_provider(module, handler_service),
732 _shutdown(false),
733 _handler_count(),
734- _service_provider(static_cast<service_provider&>(creator.get_core().get_service("event"))),
735+ _service(static_cast<libevent::service&>(module.get_core().get_service("event"))),
736 _handler_mutex(),
737 _shutdown_notification(),
738 _handlers()
739 {
740 int return_code = pthread_mutex_init(&_handler_mutex, NULL);
741 if (return_code != 0)
742- _module.log_fatal(_("Failed pthread_mutex_init: %s"), strerror(return_code));
743+ {
744+ _module.log_fatal(_("Failed pthread_mutex_init: %s:%d"),
745+ strerror(return_code), return_code);
746+ }
747 }
748
749-service::~service()
750+handler_service_provider::~handler_service_provider()
751 {
752 int return_code = pthread_mutex_destroy(&_handler_mutex);
753 if (return_code != 0)
754- _module.log_error(_("Failed pthread_mutex_destroy: %s"), strerror(return_code));
755+ {
756+ _module.log_error(_("Failed pthread_mutex_destroy: %s:%d"),
757+ strerror(return_code), return_code);
758+ }
759 }
760
761-void service::add_handler(handler* new_handler)
762+void handler_service_provider::add_handler(handler* handler)
763 {
764- _service_provider.add_handler(new_handler);
765+ _service.add_handler(handler, *this);
766
767- pthread_mutex_lock(&_handler_mutex);
768+ int return_code = pthread_mutex_lock(&_handler_mutex);
769+ if (return_code != 0)
770+ {
771+ _module.log_fatal(_("Failed pthread_mutex_lock: %s:%d"),
772+ strerror(return_code), return_code);
773+ }
774
775 try
776 {
777- _handlers.insert(new_handler);
778+ _handlers.insert(handler);
779 ++_handler_count;
780 }
781 catch (exception&)
782 {
783- pthread_mutex_unlock(&_handler_mutex);
784+ return_code = pthread_mutex_unlock(&_handler_mutex);
785+ if (return_code != 0)
786+ {
787+ _module.log_error(_("Failed pthread_mutex_unlock: %s:%d"),
788+ strerror(return_code), return_code);
789+ }
790+
791 throw;
792 }
793
794- pthread_mutex_unlock(&_handler_mutex);
795-
796- if (_shutdown)
797- new_handler->remove();
798-}
799-
800-void service::shutdown(void)
801+ return_code = pthread_mutex_unlock(&_handler_mutex);
802+ if (return_code != 0)
803+ {
804+ _module.log_fatal(_("Failed pthread_mutex_unlock: %s:%d"),
805+ strerror(return_code), return_code);
806+ }
807+
808+ if (_shutdown)
809+ handler->remove();
810+}
811+
812+void handler_service_provider::remove_handler(handler* handler)
813+{
814+ int return_code = pthread_mutex_lock(&_handler_mutex);
815+ if (return_code != 0)
816+ {
817+ _module.log_fatal(_("Failed pthread_mutex_lock: %s:%d"),
818+ strerror(return_code), return_code);
819+ }
820+
821+ _handlers.erase(handler);
822+
823+ return_code = pthread_mutex_unlock(&_handler_mutex);
824+ if (return_code != 0)
825+ {
826+ _module.log_fatal(_("Failed pthread_mutex_unlock: %s:%d"),
827+ strerror(return_code), return_code);
828+ }
829+
830+ event::handler_service_provider::remove_handler(handler);
831+
832+ /* TODO Replace this lock/decrement with an atomic op at some point. */
833+ return_code = pthread_mutex_lock(&_handler_mutex);
834+ if (return_code != 0)
835+ {
836+ _module.log_fatal(_("Failed pthread_mutex_lock: %s:%d"),
837+ strerror(return_code), return_code);
838+ }
839+
840+ --_handler_count;
841+
842+ if (_shutdown)
843+ _shutdown_notification.send();
844+
845+ return_code = pthread_mutex_unlock(&_handler_mutex);
846+ if (return_code != 0)
847+ {
848+ _module.log_fatal(_("Failed pthread_mutex_unlock: %s:%d"),
849+ strerror(return_code), return_code);
850+ }
851+}
852+
853+void handler_service_provider::shutdown(void)
854 {
855 _shutdown = true;
856
857- pthread_mutex_lock(&_handler_mutex);
858+ int return_code = pthread_mutex_lock(&_handler_mutex);
859+ if (return_code != 0)
860+ {
861+ _module.log_fatal(_("Failed pthread_mutex_lock: %s:%d"),
862+ strerror(return_code), return_code);
863+ }
864+
865 for_each(_handlers.begin(), _handlers.end(), mem_fun(&handler::remove));
866
867 while (_handler_count > 0)
868 {
869- pthread_mutex_unlock(&_handler_mutex);
870+ return_code = pthread_mutex_unlock(&_handler_mutex);
871+ if (return_code != 0)
872+ {
873+ _module.log_fatal(_("Failed pthread_mutex_unlock: %s:%d"),
874+ strerror(return_code), return_code);
875+ }
876+
877 _shutdown_notification.wait();
878- pthread_mutex_lock(&_handler_mutex);
879- }
880-
881- pthread_mutex_unlock(&_handler_mutex);
882-}
883-
884-/*
885- * Private methods.
886- */
887-
888-void service::_remove_handler(handler* old_handler)
889-{
890- pthread_mutex_lock(&_handler_mutex);
891- _handlers.erase(old_handler);
892- pthread_mutex_unlock(&_handler_mutex);
893-
894- remove_handler(old_handler);
895-
896- /* TODO Replace this lock/decrement with an atomic op at some point. */
897- pthread_mutex_lock(&_handler_mutex);
898-
899- --_handler_count;
900-
901- if (_shutdown)
902- _shutdown_notification.send();
903-
904- pthread_mutex_unlock(&_handler_mutex);
905-}
906-
907+
908+ return_code = pthread_mutex_lock(&_handler_mutex);
909+ if (return_code != 0)
910+ {
911+ _module.log_fatal(_("Failed pthread_mutex_lock: %s:%d"),
912+ strerror(return_code), return_code);
913+ }
914+ }
915+
916+ return_code = pthread_mutex_unlock(&_handler_mutex);
917+ if (return_code != 0)
918+ {
919+ _module.log_fatal(_("Failed pthread_mutex_unlock: %s:%d"),
920+ strerror(return_code), return_code);
921+ }
922+}
923+
924+} /* namespace libevent */
925 } /* namespace event */
926 } /* namespace scalestack */
927
928=== renamed file 'scalestack/event/service_provider.h' => 'scalestack/event/libevent/handler_service_provider.h'
929--- scalestack/event/service_provider.h 2010-06-03 04:51:37 +0000
930+++ scalestack/event/libevent/handler_service_provider.h 2010-06-16 19:32:28 +0000
931@@ -10,44 +10,53 @@
932
933 /**
934 * @file
935- * @brief Event Service Provider Declarations
936+ * @brief libevent Event Handler Service Provider Declarations
937 */
938
939-#ifndef SCALESTACK_EVENT_SERVICE_PROVIDER_H
940-#define SCALESTACK_EVENT_SERVICE_PROVIDER_H
941+#ifndef SCALESTACK_EVENT_LIBEVENT_HANDLER_SERVICE_PROVIDER_H
942+#define SCALESTACK_EVENT_LIBEVENT_HANDLER_SERVICE_PROVIDER_H
943+
944+#include <pthread.h>
945+#include <set>
946
947 #include <scalestack/common/macros.h>
948-#include <scalestack/event/handler.h>
949-#include <scalestack/event/service.h>
950-#include <scalestack/kernel/service.h>
951+#include <scalestack/event/handler_service.h>
952
953 namespace scalestack
954 {
955 namespace event
956 {
957+namespace libevent
958+{
959
960-class handler;
961+class service;
962
963 /**
964- * This is a base class that event service provider modules must implement.
965+ * This is the handler service provider implementation.
966 */
967-class SCALESTACK_API service_provider: public kernel::service
968+class SCALESTACK_API handler_service_provider: public event::handler_service_provider
969 {
970 public:
971
972- service_provider(kernel::module& creator);
973-
974- virtual ~service_provider();
975-
976- /**
977- * See service::add_handler().
978- */
979- virtual void add_handler(handler* new_handler) = 0;
980-
981- /**
982- * See service::remove_handler().
983- */
984- void remove_handler(handler* old_handler);
985+ handler_service_provider(kernel::module& module,
986+ event::handler_service& handler_service);
987+
988+ virtual ~handler_service_provider();
989+
990+ /**
991+ * See event::handler_service::add_handler().
992+ */
993+ void add_handler(handler* handler);
994+
995+ /**
996+ * See event::handler_service::remove_handler().
997+ */
998+ void remove_handler(handler* handler);
999+
1000+ /**
1001+ * See event::handler_service::shutdown().
1002+ */
1003+ void shutdown(void);
1004
1005 private:
1006
1007@@ -55,34 +64,26 @@
1008 * Don't allow copying of objects.
1009 */
1010 SCALESTACK_LOCAL
1011- service_provider(const service_provider&);
1012+ handler_service_provider(const handler_service_provider&);
1013
1014 /**
1015 * Don't allow assignment of objects.
1016 */
1017 SCALESTACK_LOCAL
1018- service_provider& operator=(const service_provider&);
1019+ handler_service_provider& operator=(const handler_service_provider&);
1020+
1021+ typedef std::set<handler*> handlers;
1022+
1023+ bool _shutdown;
1024+ size_t _handler_count;
1025+ libevent::service& _service;
1026+ pthread_mutex_t _handler_mutex;
1027+ common::notification _shutdown_notification;
1028+ handlers _handlers;
1029 };
1030
1031-/*
1032- * Public methods.
1033- */
1034-
1035-inline service_provider::service_provider(kernel::module& creator):
1036- kernel::service(creator)
1037-{
1038-}
1039-
1040-inline service_provider::~service_provider()
1041-{
1042-}
1043-
1044-inline void service_provider::remove_handler(handler* old_handler)
1045-{
1046- old_handler->get_service()._remove_handler(old_handler);
1047-}
1048-
1049+} /* namespace libevent */
1050 } /* namespace event */
1051 } /* namespace scalestack */
1052
1053-#endif /* SCALESTACK_EVENT_SERVICE_PROVIDER_H */
1054+#endif /* SCALESTACK_EVENT_LIBEVENT_HANDLER_SERVICE_PROVIDER_H */
1055
1056=== modified file 'scalestack/event/libevent/libevent.cc'
1057--- scalestack/event/libevent/libevent.cc 2010-06-03 04:51:37 +0000
1058+++ scalestack/event/libevent/libevent.cc 2010-06-16 19:32:28 +0000
1059@@ -16,8 +16,9 @@
1060 #include "config.h"
1061
1062 #include <exception>
1063+#include <memory>
1064
1065-#include <scalestack/event/libevent/service_provider.h>
1066+#include <scalestack/event/libevent/service.h>
1067 #include <scalestack/kernel/core.h>
1068 #include <scalestack/kernel/module.h>
1069
1070@@ -26,22 +27,21 @@
1071
1072 static void options(kernel::module& module)
1073 {
1074- module.add_option("threads", "Number of event threads to use.", "THREADS", "1");
1075- module.add_option("thread_stack_size", "Size of the stack for threads.", "STACKSIZE", "0");
1076+ module.add_option("threads",
1077+ "Number of event threads to use.",
1078+ "THREADS",
1079+ "1");
1080+ module.add_option("thread_stack_size",
1081+ "Size of the stack for threads (0 means default).",
1082+ "STACKSIZE",
1083+ "0");
1084 }
1085
1086 static void start(kernel::module& module)
1087 {
1088- event::libevent::service_provider* service_provider = new event::libevent::service_provider(module);
1089- try
1090- {
1091- module.get_core().add_service("event", service_provider);
1092- }
1093- catch (exception&)
1094- {
1095- delete service_provider;
1096- throw;
1097- }
1098+ auto_ptr<event::libevent::service> service(new event::libevent::service(module));
1099+ module.get_core().add_service("event", service.get());
1100+ service.release();
1101 }
1102
1103 static void stop(kernel::module& module)
1104
1105=== modified file 'scalestack/event/libevent/plugin.ini'
1106--- scalestack/event/libevent/plugin.ini 2010-06-03 04:51:37 +0000
1107+++ scalestack/event/libevent/plugin.ini 2010-06-16 19:32:28 +0000
1108@@ -4,8 +4,8 @@
1109 version=0.1
1110 author=Eric Day <eday@oddments.org>
1111 license=BSD
1112-sources=libevent.cc handler_provider.cc service_provider.cc thread.cc
1113-headers=handler_provider.h service_provider.h thread.h
1114+sources=libevent.cc handler_provider.cc handler_service_provider.cc service.cc thread.cc
1115+headers=handler_provider.h handler_service_provider.h service.h thread.h
1116 dependencies=event
1117 ldflags=${LTLIBEVENT}
1118 build_conditional="x$ac_cv_func_event_base_new" = "xyes"
1119
1120=== renamed file 'scalestack/event/libevent/service_provider.cc' => 'scalestack/event/libevent/service.cc'
1121--- scalestack/event/libevent/service_provider.cc 2010-06-03 04:51:37 +0000
1122+++ scalestack/event/libevent/service.cc 2010-06-16 19:32:28 +0000
1123@@ -18,10 +18,11 @@
1124 #include <algorithm>
1125 #include <exception>
1126 #include <functional>
1127+#include <memory>
1128
1129-#include <scalestack/event/service.h>
1130 #include <scalestack/event/libevent/handler_provider.h>
1131-#include <scalestack/event/libevent/service_provider.h>
1132+#include <scalestack/event/libevent/handler_service_provider.h>
1133+#include <scalestack/event/libevent/service.h>
1134 #include <scalestack/event/libevent/thread.h>
1135 #include <scalestack/kernel/module.h>
1136 #include <scalestack/kernel/option.h>
1137@@ -39,8 +40,8 @@
1138 * Public methods.
1139 */
1140
1141-service_provider::service_provider(kernel::module& module):
1142- event::service_provider(module),
1143+service::service(kernel::module& module):
1144+ event::service(module),
1145 _current_thread(),
1146 _threads()
1147 {
1148@@ -50,18 +51,18 @@
1149
1150 for (size_t thread_index = 0; thread_index < thread_count; thread_index++)
1151 {
1152- thread* new_thread = NULL;
1153+ thread* thread = NULL;
1154 try
1155 {
1156- new_thread = new thread(*this, thread_index);
1157- _threads.push_back(new_thread);
1158+ thread = new libevent::thread(*this, thread_index);
1159+ _threads.push_back(thread);
1160 }
1161 catch (exception&)
1162 {
1163- if (new_thread != NULL)
1164+ if (thread != NULL)
1165 {
1166- new_thread->stop();
1167- delete new_thread;
1168+ thread->stop();
1169+ delete thread;
1170 }
1171
1172 _remove_threads();
1173@@ -70,32 +71,28 @@
1174 }
1175 }
1176
1177-service_provider::~service_provider()
1178+service::~service()
1179 {
1180 _remove_threads();
1181 }
1182
1183-void service_provider::add_handler(event::handler* handler)
1184+void service::add_handler(event::handler* handler,
1185+ handler_service_provider& handler_service_provider)
1186 {
1187- handler_provider* new_handler_provider = new handler_provider(_module);
1188- try
1189- {
1190- new_handler_provider->set_handler(handler);
1191-
1192- /* Choose assigned thread by round-robin. */
1193- _current_thread++;
1194- new_handler_provider->set_thread(_threads[_current_thread % _threads.size()]);
1195- }
1196- catch (exception&)
1197- {
1198- delete new_handler_provider;
1199- throw;
1200- }
1201+ auto_ptr<handler_provider> handler_provider(new libevent::handler_provider(_module, handler_service_provider));
1202+
1203+ handler_provider->set_handler(handler);
1204+
1205+ /* Choose assigned thread by round-robin. */
1206+ _current_thread++;
1207+ handler_provider->set_thread(_threads[_current_thread % _threads.size()]);
1208+
1209+ handler_provider.release();
1210 }
1211
1212-void service_provider::remove_handler_provider(handler_provider* handler_provider)
1213+void service::remove_handler(handler_provider* handler_provider)
1214 {
1215- remove_handler(handler_provider->get_handler());
1216+ handler_provider->get_handler_service_provider().remove_handler(handler_provider->get_handler());
1217 delete handler_provider;
1218 }
1219
1220@@ -103,11 +100,11 @@
1221 * Private methods.
1222 */
1223
1224-void service_provider::_remove_threads(void)
1225+void service::_remove_threads(void)
1226 {
1227 for_each(_threads.begin(), _threads.end(), mem_fun(&thread::stop));
1228
1229- for (vector<thread*>::iterator thread = _threads.begin();
1230+ for (threads::iterator thread = _threads.begin();
1231 thread != _threads.end();
1232 ++thread)
1233 {
1234@@ -115,6 +112,16 @@
1235 }
1236 }
1237
1238+event::handler_service_provider& service::_add_handler_service(event::handler_service& handler_service)
1239+{
1240+ return *(new handler_service_provider(_module, handler_service));
1241+}
1242+
1243+void service::_remove_handler_service(event::handler_service_provider& handler_service_provider)
1244+{
1245+ delete &handler_service_provider;
1246+}
1247+
1248 } /* namespace libevent */
1249 } /* namespace event */
1250 } /* namespace scalestack */
1251
1252=== renamed file 'scalestack/event/libevent/service_provider.h' => 'scalestack/event/libevent/service.h'
1253--- scalestack/event/libevent/service_provider.h 2010-06-03 04:51:37 +0000
1254+++ scalestack/event/libevent/service.h 2010-06-16 19:32:28 +0000
1255@@ -10,28 +10,31 @@
1256
1257 /**
1258 * @file
1259- * @brief libevent Event Service Provider Declarations
1260+ * @brief libevent Event Service Declarations
1261 */
1262
1263-#ifndef SCALESTACK_EVENT_LIBEVENT_SERVICE_PROVIDER_H
1264-#define SCALESTACK_EVENT_LIBEVENT_SERVICE_PROVIDER_H
1265+#ifndef SCALESTACK_EVENT_LIBEVENT_SERVICE_H
1266+#define SCALESTACK_EVENT_LIBEVENT_SERVICE_H
1267
1268 #include <vector>
1269
1270 #include <scalestack/common/macros.h>
1271-#include <scalestack/event/service_provider.h>
1272+#include <scalestack/event/service.h>
1273
1274 namespace scalestack
1275 {
1276 namespace event
1277 {
1278+
1279+class handler;
1280+
1281 namespace libevent
1282 {
1283
1284 class handler_provider;
1285 class thread;
1286
1287-class SCALESTACK_API service_provider: public event::service_provider
1288+class SCALESTACK_API service: public event::service
1289 {
1290 public:
1291
1292@@ -40,21 +43,26 @@
1293 *
1294 * @param[in] module Module that the service is associated with.
1295 */
1296- service_provider(kernel::module& module);
1297+ service(kernel::module& module);
1298
1299- ~service_provider();
1300+ ~service();
1301
1302 /**
1303- * See event::service::add_handler().
1304+ * Add a handler to one of the threads in the service pool.
1305+ *
1306+ * @param[in] handler Handler to add.
1307+ * @param[in] handler_service_provider Handler service the handler
1308+ * belongs to.
1309 */
1310- void add_handler(event::handler* handler);
1311+ void add_handler(event::handler* handler,
1312+ handler_service_provider& handler_service_provider);
1313
1314 /**
1315- * Remove handler provider that was previously added in add_handler().
1316+ * Remove handler that was previously added in add_handler().
1317 *
1318 * @param[in] handler_provider Handler provider to remove.
1319 */
1320- void remove_handler_provider(handler_provider* handler_provider);
1321+ void remove_handler(handler_provider* handler_provider);
1322
1323 private:
1324
1325@@ -62,25 +70,37 @@
1326 * Don't allow copying of objects.
1327 */
1328 SCALESTACK_LOCAL
1329- service_provider(const service_provider&);
1330+ service(const service&);
1331
1332 /**
1333 * Don't allow assignment of objects.
1334 */
1335 SCALESTACK_LOCAL
1336- service_provider& operator=(const service_provider&);
1337+ service& operator=(const service&);
1338
1339 /**
1340 * Remove all threads that were created in the constructor.
1341 */
1342 void _remove_threads(void);
1343
1344+ /**
1345+ * See event::service::_add_handler_service().
1346+ */
1347+ event::handler_service_provider& _add_handler_service(event::handler_service& handler_service);
1348+
1349+ /**
1350+ * See event::service::_remove_handler_service().
1351+ */
1352+ void _remove_handler_service(event::handler_service_provider& handler_service_provider);
1353+
1354+ typedef std::vector<thread*> threads;
1355+
1356 size_t _current_thread;
1357- std::vector<thread*> _threads;
1358+ threads _threads;
1359 };
1360
1361 } /* namespace libevent */
1362 } /* namespace event */
1363 } /* namespace scalestack */
1364
1365-#endif /* SCALESTACK_EVENT_LIBEVENT_SERVICE_PROVIDER_H */
1366+#endif /* SCALESTACK_EVENT_LIBEVENT_SERVICE_H */
1367
1368=== modified file 'scalestack/event/libevent/thread.cc'
1369--- scalestack/event/libevent/thread.cc 2010-06-03 04:51:37 +0000
1370+++ scalestack/event/libevent/thread.cc 2010-06-16 19:32:28 +0000
1371@@ -17,12 +17,13 @@
1372
1373 #include <algorithm>
1374 #include <cerrno>
1375+#include <cstring>
1376 #include <fcntl.h>
1377 #include <functional>
1378 #include <unistd.h>
1379
1380 #include <scalestack/event/libevent/handler_provider.h>
1381-#include <scalestack/event/libevent/service_provider.h>
1382+#include <scalestack/event/libevent/service.h>
1383 #include <scalestack/event/libevent/thread.h>
1384 #include <scalestack/kernel/core.h>
1385 #include <scalestack/kernel/module.h>
1386@@ -43,28 +44,28 @@
1387
1388 extern "C" void* thread_run(void* context)
1389 {
1390- thread* new_thread = static_cast<thread*>(context);
1391- new_thread->_run();
1392+ thread* thread = static_cast<libevent::thread*>(context);
1393+ thread->_run();
1394 return NULL;
1395 }
1396
1397 extern "C" void thread_handle_notification(int file_descriptor, short events,
1398 void* context)
1399 {
1400- thread* current_thread = static_cast<thread*>(context);
1401- current_thread->_handle_notification(file_descriptor, events);
1402+ thread* thread = static_cast<libevent::thread*>(context);
1403+ thread->_handle_notification(file_descriptor, events);
1404 }
1405
1406 /*
1407 * Public methods.
1408 */
1409
1410-thread::thread(service_provider& service_provider, size_t thread_index):
1411+thread::thread(service& service, size_t thread_index):
1412 _shutdown(false),
1413 _handler_providers_index(),
1414 _thread_index(thread_index),
1415- _module(service_provider.get_module()),
1416- _service_provider(service_provider),
1417+ _module(service.get_module()),
1418+ _service(service),
1419 _base(),
1420 _notification_pipe(),
1421 _thread_id(),
1422@@ -75,7 +76,7 @@
1423 _handler_providers()
1424 {
1425 if (gettimeofday(&_now, 0) == -1)
1426- _module.log_fatal("Failed gettimeofday: %d", errno);
1427+ _module.log_fatal("Failed gettimeofday: %s:%d", strerror(errno), errno);
1428
1429 _base = event_base_new();
1430 if (_base == NULL)
1431@@ -135,13 +136,23 @@
1432
1433 void thread::check_handler_provider(handler_provider* handler_provider)
1434 {
1435- pthread_mutex_lock(&_handler_providers_mutex);
1436+ int return_code = pthread_mutex_lock(&_handler_providers_mutex);
1437+ if (return_code != 0)
1438+ {
1439+ _module.log_fatal("Failed pthread_mutex_lock: %s:%d",
1440+ strerror(return_code), return_code);
1441+ }
1442
1443 /* Double check queue flag inside lock to avoid race conditions. */
1444 if (handler_provider->add_to_check_queue())
1445 _handler_providers[_handler_providers_index].push_back(handler_provider);
1446
1447- pthread_mutex_unlock(&_handler_providers_mutex);
1448+ return_code = pthread_mutex_unlock(&_handler_providers_mutex);
1449+ if (return_code != 0)
1450+ {
1451+ _module.log_fatal("Failed pthread_mutex_unlock: %s:%d",
1452+ strerror(return_code), return_code);
1453+ }
1454
1455 _send_notification();
1456 }
1457@@ -177,7 +188,7 @@
1458 {
1459 int return_code = pipe(_notification_pipe);
1460 if (return_code == -1)
1461- _module.log_fatal("Failed pipe: %d", errno);
1462+ _module.log_fatal("Failed pipe: %s:%d", strerror(errno), errno);
1463
1464 for (int index = 0; index < 2; index++)
1465 {
1466@@ -185,14 +196,14 @@
1467 if (return_code == -1)
1468 {
1469 _remove_notification_pipe();
1470- _module.log_fatal("Failed fcntl: %d", errno);
1471+ _module.log_fatal("Failed fcntl: %s:%d", strerror(errno), errno);
1472 }
1473
1474 return_code = fcntl(_notification_pipe[index], F_SETFL, return_code | O_NONBLOCK);
1475 if (return_code == -1)
1476 {
1477 _remove_notification_pipe();
1478- _module.log_fatal("Failed fcntl: %d", errno);
1479+ _module.log_fatal("Failed fcntl: %s:%d", strerror(errno), errno);
1480 }
1481 }
1482
1483@@ -223,7 +234,10 @@
1484 void thread::_send_notification(void)
1485 {
1486 if (write(_notification_pipe[1], "\0", 1) == -1)
1487- _module.log_error("Could not write to notification pipe: %d", errno);
1488+ {
1489+ _module.log_error("Could not write to notification pipe: %s:%d",
1490+ strerror(errno), errno);
1491+ }
1492 }
1493
1494 void thread::_handle_notification(int file_descriptor, short events)
1495@@ -234,7 +248,10 @@
1496 {
1497 char buffer[1024];
1498 if (read(file_descriptor, buffer, sizeof(buffer)) == -1)
1499- _module.log_error("Could not read from notification pipe: %d", errno);
1500+ {
1501+ _module.log_error("Could not read from notification pipe: %s:%d",
1502+ strerror(errno), errno);
1503+ }
1504 }
1505
1506 if (event_del(&_notification_event) == -1)
1507@@ -254,21 +271,34 @@
1508 }
1509
1510 if (gettimeofday(&_now, 0) == -1)
1511- _module.log_error("Failed gettimeofday: %d", errno);
1512+ _module.log_error("Failed gettimeofday: %s:%d", strerror(errno), errno);
1513
1514 /* Just switch the index, keep lock time to a minimum. */
1515 uint8_t index = _handler_providers_index;
1516- pthread_mutex_lock(&_handler_providers_mutex);
1517+
1518+ int return_code = pthread_mutex_lock(&_handler_providers_mutex);
1519+ if (return_code != 0)
1520+ {
1521+ _module.log_fatal("Failed pthread_mutex_lock: %s:%d",
1522+ strerror(return_code), return_code);
1523+ }
1524+
1525 _handler_providers_index = static_cast<uint8_t>(1 - _handler_providers_index);
1526- pthread_mutex_unlock(&_handler_providers_mutex);
1527-
1528- vector<handler_provider*>::iterator handler_provider;
1529+
1530+ return_code = pthread_mutex_unlock(&_handler_providers_mutex);
1531+ if (return_code != 0)
1532+ {
1533+ _module.log_fatal("Failed pthread_mutex_unlock: %s:%d",
1534+ strerror(return_code), return_code);
1535+ }
1536+
1537+ handler_providers::iterator handler_provider;
1538 for (handler_provider = _handler_providers[index].begin();
1539 handler_provider != _handler_providers[index].end();
1540 ++handler_provider)
1541 {
1542 if ((*handler_provider)->need_remove())
1543- _service_provider.remove_handler_provider(*handler_provider);
1544+ _service.remove_handler(*handler_provider);
1545 else
1546 (*handler_provider)->check();
1547 }
1548@@ -280,14 +310,20 @@
1549 {
1550 int return_code = pthread_mutex_init(&_handler_providers_mutex, NULL);
1551 if (return_code != 0)
1552- _module.log_fatal("Failed pthread_mutex_init: %d", return_code);
1553+ {
1554+ _module.log_fatal("Failed pthread_mutex_init: %s:%d",
1555+ strerror(return_code), return_code);
1556+ }
1557 }
1558
1559 void thread::_remove_mutexes(void)
1560 {
1561 int return_code = pthread_mutex_destroy(&_handler_providers_mutex);
1562 if (return_code != 0)
1563- _module.log_error("Failed pthread_mutex_destroy: %d", return_code);
1564+ {
1565+ _module.log_error("Failed pthread_mutex_destroy: %s:%d",
1566+ strerror(return_code), return_code);
1567+ }
1568 }
1569
1570 void thread::_add_thread(void)
1571@@ -296,7 +332,10 @@
1572
1573 int return_code = pthread_attr_init(&thread_attribute);
1574 if (return_code != 0)
1575- _module.log_fatal("Failed pthread_attr_init: %d", return_code);
1576+ {
1577+ _module.log_fatal("Failed pthread_attr_init: %s:%d",
1578+ strerror(return_code), return_code);
1579+ }
1580
1581 size_t stack_size = _module.get_option("thread_stack_size").get_size_value();
1582 if (stack_size != 0)
1583@@ -305,7 +344,8 @@
1584 if (return_code != 0)
1585 {
1586 (void) pthread_attr_destroy(&thread_attribute);
1587- _module.log_fatal("Failed pthread_attr_setstacksize: %d", return_code);
1588+ _module.log_fatal("Failed pthread_attr_setstacksize: %s:%d",
1589+ strerror(return_code), return_code);
1590 }
1591 }
1592
1593@@ -313,26 +353,34 @@
1594 if (return_code != 0)
1595 {
1596 (void) pthread_attr_destroy(&thread_attribute);
1597- _module.log_fatal("Failed pthread_attr_setscope: %d", return_code);
1598+ _module.log_fatal("Failed pthread_attr_setscope: %s:%d",
1599+ strerror(return_code), return_code);
1600 }
1601
1602 return_code = pthread_create(&_thread_id, &thread_attribute, thread_run, this);
1603 if (return_code != 0)
1604 {
1605 (void) pthread_attr_destroy(&thread_attribute);
1606- _module.log_fatal("Failed pthread_create: %d", return_code);
1607+ _module.log_fatal("Failed pthread_create: %s:%d",
1608+ strerror(return_code), return_code);
1609 }
1610
1611 return_code = pthread_attr_destroy(&thread_attribute);
1612 if (return_code != 0)
1613- _module.log_error("Failed pthread_attr_destroy: %d", return_code);
1614+ {
1615+ _module.log_error("Failed pthread_attr_destroy: %s:%d",
1616+ strerror(return_code), return_code);
1617+ }
1618 }
1619
1620 void thread::_remove_thread(void)
1621 {
1622 int return_code = pthread_join(_thread_id, NULL);
1623 if (return_code != 0)
1624- _module.log_error("Failed pthread_join: %d", return_code);
1625+ {
1626+ _module.log_error("Failed pthread_join: %s:%d",
1627+ strerror(return_code), return_code);
1628+ }
1629 }
1630
1631 } /* namespace libevent */
1632
1633=== modified file 'scalestack/event/libevent/thread.h'
1634--- scalestack/event/libevent/thread.h 2010-06-03 04:51:37 +0000
1635+++ scalestack/event/libevent/thread.h 2010-06-16 19:32:28 +0000
1636@@ -38,7 +38,7 @@
1637 {
1638
1639 class handler_provider;
1640-class service_provider;
1641+class service;
1642
1643 /**
1644 * Function passed to pthread_create() to invoke thread::_run().
1645@@ -48,15 +48,12 @@
1646 /**
1647 * Function used by notification event to invoke thread::_handle_notification().
1648 */
1649-extern "C" void thread_handle_notification(int file_descriptor, short events,
1650+extern "C" void thread_handle_notification(int file_descriptor,
1651+ short events,
1652 void* context);
1653
1654 class thread
1655 {
1656- friend void* thread_run(void*);
1657- friend void thread_handle_notification(int file_descriptor, short events,
1658- void* context);
1659-
1660 public:
1661
1662 /**
1663@@ -64,10 +61,10 @@
1664 * starting this call, the _run() method can be called at any time, even
1665 * before the constructor completes.
1666 *
1667- * @param[in] service_provider Service provider creating this thread.
1668+ * @param[in] service Service that is creating this thread.
1669 * @param[in] thread_index The 0-based index for this thread.
1670 */
1671- thread(service_provider& service_provider, size_t thread_index);
1672+ thread(service& service, size_t thread_index);
1673
1674 ~thread();
1675
1676@@ -164,11 +161,13 @@
1677 SCALESTACK_LOCAL
1678 void _remove_thread(void);
1679
1680+ typedef std::vector<handler_provider*> handler_providers;
1681+
1682 bool _shutdown;
1683 uint8_t _handler_providers_index;
1684 size_t _thread_index;
1685 kernel::module& _module;
1686- service_provider& _service_provider;
1687+ service& _service;
1688 struct event_base* _base;
1689 int _notification_pipe[2];
1690 pthread_t _thread_id;
1691@@ -176,7 +175,12 @@
1692 struct timeval _notification_timeout;
1693 struct timeval _now;
1694 pthread_mutex_t _handler_providers_mutex;
1695- std::vector<handler_provider*> _handler_providers[2];
1696+ handler_providers _handler_providers[2];
1697+
1698+ friend void* thread_run(void*);
1699+ friend void thread_handle_notification(int file_descriptor,
1700+ short events,
1701+ void* context);
1702 };
1703
1704 } /* namespace libevent */
1705
1706=== modified file 'scalestack/event/plugin.ini'
1707--- scalestack/event/plugin.ini 2010-06-03 04:51:37 +0000
1708+++ scalestack/event/plugin.ini 2010-06-16 19:32:28 +0000
1709@@ -4,5 +4,5 @@
1710 version=0.1
1711 author=Eric Day <eday@oddments.org>
1712 license=BSD
1713-sources=event.cc service.cc
1714-install_headers=handler.h service.h service_provider.h
1715+sources=event.cc
1716+install_headers=handler.h handler_service.h service.h
1717
1718=== added file 'scalestack/event/service.h'
1719--- scalestack/event/service.h 1970-01-01 00:00:00 +0000
1720+++ scalestack/event/service.h 2010-06-16 19:32:28 +0000
1721@@ -0,0 +1,95 @@
1722+/*
1723+ * Scale Stack
1724+ *
1725+ * Copyright (C) 2010 Eric Day (eday@oddments.org)
1726+ * All rights reserved.
1727+ *
1728+ * Use and distribution licensed under the BSD license. See the
1729+ * COPYING file in the root project directory for full text.
1730+ */
1731+
1732+/**
1733+ * @file
1734+ * @brief Event Service Declarations
1735+ */
1736+
1737+#ifndef SCALESTACK_EVENT_SERVICE_H
1738+#define SCALESTACK_EVENT_SERVICE_H
1739+
1740+#include <scalestack/common/macros.h>
1741+#include <scalestack/kernel/service.h>
1742+
1743+namespace scalestack
1744+{
1745+namespace event
1746+{
1747+
1748+class handler_service;
1749+class handler_service_provider;
1750+
1751+/**
1752+ * This is a base class that event providers must implement in order to
1753+ * provide an event service.
1754+ */
1755+class SCALESTACK_API service: public kernel::service
1756+{
1757+public:
1758+
1759+ /**
1760+ * Constructor for event service.
1761+ *
1762+ * @param[in] module Module that the service is associated with.
1763+ */
1764+ service(kernel::module& module);
1765+
1766+ virtual ~service();
1767+
1768+private:
1769+
1770+ /**
1771+ * Don't allow copying of objects.
1772+ */
1773+ SCALESTACK_LOCAL
1774+ service(const service&);
1775+
1776+ /**
1777+ * Don't allow assignment of objects.
1778+ */
1779+ SCALESTACK_LOCAL
1780+ service& operator=(const service&);
1781+
1782+ /**
1783+ * Add a handler service to the event service.
1784+ *
1785+ * @param[in] handler_service Handler service to add.
1786+ * @return Handler service provider to use with the handler service.
1787+ */
1788+ virtual handler_service_provider& _add_handler_service(handler_service& handler_service) = 0;
1789+
1790+ /**
1791+ * Remove a handler service provider from an event service.
1792+ *
1793+ * @param[in] handler_service_provider Handler service provider to remove.
1794+ */
1795+ virtual void _remove_handler_service(handler_service_provider& handler_service_provider) = 0;
1796+
1797+ friend class handler_service;
1798+};
1799+
1800+/*
1801+ * Public handler_service methods.
1802+ */
1803+
1804+inline service::service(kernel::module& module):
1805+ kernel::service(module)
1806+{
1807+}
1808+
1809+inline service::~service()
1810+{
1811+}
1812+
1813+} /* namespace event */
1814+} /* namespace scalestack */
1815+
1816+#endif /* SCALESTACK_EVENT_SERVICE_H */
1817
1818=== modified file 'scalestack/event/test/handler.cc'
1819--- scalestack/event/test/handler.cc 2010-06-03 04:51:37 +0000
1820+++ scalestack/event/test/handler.cc 2010-06-16 19:32:28 +0000
1821@@ -28,8 +28,8 @@
1822 * Public methods.
1823 */
1824
1825-handler::handler(service& creator):
1826- event::handler(creator)
1827+handler::handler(handler_service& handler_service):
1828+ event::handler(handler_service)
1829 {
1830 }
1831
1832
1833=== modified file 'scalestack/event/test/handler.h'
1834--- scalestack/event/test/handler.h 2010-06-03 04:51:37 +0000
1835+++ scalestack/event/test/handler.h 2010-06-16 19:32:28 +0000
1836@@ -30,7 +30,7 @@
1837 {
1838 public:
1839
1840- handler(service& creator);
1841+ handler(handler_service& handler_service);
1842
1843 ~handler();
1844
1845
1846=== modified file 'scalestack/event/test/handler_provider.cc'
1847--- scalestack/event/test/handler_provider.cc 2010-06-03 04:51:37 +0000
1848+++ scalestack/event/test/handler_provider.cc 2010-06-16 19:32:28 +0000
1849@@ -16,7 +16,7 @@
1850 #include "config.h"
1851
1852 #include <scalestack/event/test/handler_provider.h>
1853-#include <scalestack/event/test/service_provider.h>
1854+#include <scalestack/event/test/handler_service_provider.h>
1855
1856 namespace scalestack
1857 {
1858@@ -29,8 +29,8 @@
1859 * Public methods.
1860 */
1861
1862-handler_provider::handler_provider(service_provider& creator):
1863- _service_provider(creator)
1864+handler_provider::handler_provider(handler_service_provider& handler_service_provider):
1865+ _handler_service_provider(handler_service_provider)
1866 {
1867 }
1868
1869@@ -40,7 +40,7 @@
1870
1871 void handler_provider::remove(void)
1872 {
1873- _service_provider.queue_to_remove(this);
1874+ _handler_service_provider.queue_to_remove(this);
1875 }
1876
1877 void handler_provider::set_timer(time_t)
1878
1879=== modified file 'scalestack/event/test/handler_provider.h'
1880--- scalestack/event/test/handler_provider.h 2010-06-03 04:51:37 +0000
1881+++ scalestack/event/test/handler_provider.h 2010-06-16 19:32:28 +0000
1882@@ -26,13 +26,13 @@
1883 namespace test
1884 {
1885
1886-class service_provider;
1887+class handler_service_provider;
1888
1889 class SCALESTACK_API handler_provider: public event::handler_provider
1890 {
1891 public:
1892
1893- handler_provider(service_provider& creator);
1894+ handler_provider(handler_service_provider& handler_service_provider);
1895
1896 ~handler_provider();
1897
1898@@ -62,7 +62,7 @@
1899 SCALESTACK_LOCAL
1900 handler_provider& operator=(const handler_provider&);
1901
1902- service_provider& _service_provider;
1903+ handler_service_provider& _handler_service_provider;
1904 };
1905
1906 } /* namespace test */
1907
1908=== renamed file 'scalestack/event/test/service.cc' => 'scalestack/event/test/handler_service.cc'
1909--- scalestack/event/test/service.cc 2010-06-03 04:51:37 +0000
1910+++ scalestack/event/test/handler_service.cc 2010-06-16 19:32:28 +0000
1911@@ -16,7 +16,7 @@
1912 #include "config.h"
1913
1914 #include <scalestack/event/test/handler.h>
1915-#include <scalestack/event/test/service.h>
1916+#include <scalestack/event/test/handler_service.h>
1917
1918 namespace scalestack
1919 {
1920@@ -29,19 +29,19 @@
1921 * Public methods.
1922 */
1923
1924-service::service(kernel::module& creator):
1925- event::service(creator)
1926+handler_service::handler_service(kernel::module& module):
1927+ event::handler_service(module)
1928 {
1929 }
1930
1931-service::~service()
1932+handler_service::~handler_service()
1933 {
1934 shutdown();
1935 }
1936
1937-void service::remove_handler(event::handler* old_handler)
1938+void handler_service::remove_handler(event::handler* handler)
1939 {
1940- delete old_handler;
1941+ delete handler;
1942 }
1943
1944 } /* namespace test */
1945
1946=== renamed file 'scalestack/event/test/service.h' => 'scalestack/event/test/handler_service.h'
1947--- scalestack/event/test/service.h 2010-06-03 04:51:37 +0000
1948+++ scalestack/event/test/handler_service.h 2010-06-16 19:32:28 +0000
1949@@ -13,11 +13,11 @@
1950 * @brief Event Test Service Declarations
1951 */
1952
1953-#ifndef SCALESTACK_EVENT_TEST_SERVICE_H
1954-#define SCALESTACK_EVENT_TEST_SERVICE_H
1955+#ifndef SCALESTACK_EVENT_TEST_HANDLER_SERVICE_H
1956+#define SCALESTACK_EVENT_TEST_HANDLER_SERVICE_H
1957
1958 #include <scalestack/common/macros.h>
1959-#include <scalestack/event/service.h>
1960+#include <scalestack/event/handler_service.h>
1961
1962 namespace scalestack
1963 {
1964@@ -26,18 +26,18 @@
1965 namespace test
1966 {
1967
1968-class SCALESTACK_API service: public event::service
1969+class SCALESTACK_API handler_service: public event::handler_service
1970 {
1971 public:
1972
1973- service(kernel::module& creator);
1974+ handler_service(kernel::module& module);
1975
1976- ~service();
1977+ ~handler_service();
1978
1979 /**
1980- * See event::service::remove_handler().
1981+ * See event::handler_service::remove_handler().
1982 */
1983- void remove_handler(event::handler* old_handler);
1984+ void remove_handler(event::handler* handler);
1985
1986 private:
1987
1988@@ -45,17 +45,17 @@
1989 * Don't allow copying of objects.
1990 */
1991 SCALESTACK_LOCAL
1992- service(const service&);
1993+ handler_service(const handler_service&);
1994
1995 /**
1996 * Don't allow assignment of objects.
1997 */
1998 SCALESTACK_LOCAL
1999- service& operator=(const service&);
2000+ handler_service& operator=(const handler_service&);
2001 };
2002
2003 } /* namespace test */
2004 } /* namespace event */
2005 } /* namespace scalestack */
2006
2007-#endif /* SCALESTACK_EVENT_TEST_SERVICE_H */
2008+#endif /* SCALESTACK_EVENT_TEST_HANDLER_SERVICE_H */
2009
2010=== renamed file 'scalestack/event/test/service_provider.cc' => 'scalestack/event/test/handler_service_provider.cc'
2011--- scalestack/event/test/service_provider.cc 2010-06-03 04:51:37 +0000
2012+++ scalestack/event/test/handler_service_provider.cc 2010-06-16 19:32:28 +0000
2013@@ -16,7 +16,7 @@
2014 #include "config.h"
2015
2016 #include <scalestack/event/test/handler_provider.h>
2017-#include <scalestack/event/test/service_provider.h>
2018+#include <scalestack/event/test/handler_service_provider.h>
2019
2020 namespace scalestack
2021 {
2022@@ -29,32 +29,32 @@
2023 * Public methods.
2024 */
2025
2026-service_provider::service_provider(kernel::module& creator):
2027- event::service_provider(creator),
2028- _old_handler_provider()
2029-{
2030-}
2031-
2032-service_provider::~service_provider()
2033-{
2034-}
2035-
2036-void service_provider::add_handler(event::handler* new_handler)
2037-{
2038- handler_provider* new_handler_provider = new handler_provider(*this);
2039- new_handler_provider->set_handler(new_handler);
2040- new_handler_provider->start();
2041-}
2042-
2043-void service_provider::queue_to_remove(handler_provider* old_handler_provider)
2044-{
2045- _old_handler_provider = old_handler_provider;
2046-}
2047-
2048-void service_provider::check_remove_queue(void)
2049-{
2050- remove_handler(_old_handler_provider->get_handler());
2051- delete _old_handler_provider;
2052+handler_service_provider::handler_service_provider(kernel::module& module, event::handler_service& handler_service):
2053+ event::handler_service_provider(module, handler_service),
2054+ _handler_provider()
2055+{
2056+}
2057+
2058+handler_service_provider::~handler_service_provider()
2059+{
2060+}
2061+
2062+void handler_service_provider::add_handler(event::handler* handler)
2063+{
2064+ handler_provider* handler_provider = new test::handler_provider(*this);
2065+ handler_provider->set_handler(handler);
2066+ handler_provider->start();
2067+}
2068+
2069+void handler_service_provider::shutdown(void)
2070+{
2071+ remove_handler(_handler_provider->get_handler());
2072+ delete _handler_provider;
2073+}
2074+
2075+void handler_service_provider::queue_to_remove(handler_provider* handler_provider)
2076+{
2077+ _handler_provider = handler_provider;
2078 }
2079
2080 } /* namespace test */
2081
2082=== renamed file 'scalestack/event/test/service_provider.h' => 'scalestack/event/test/handler_service_provider.h'
2083--- scalestack/event/test/service_provider.h 2010-06-03 04:51:37 +0000
2084+++ scalestack/event/test/handler_service_provider.h 2010-06-16 19:32:28 +0000
2085@@ -13,11 +13,11 @@
2086 * @brief Event Test Service Provider Declarations
2087 */
2088
2089-#ifndef SCALESTACK_EVENT_TEST_SERVICE_PROVIDER_H
2090-#define SCALESTACK_EVENT_TEST_SERVICE_PROVIDER_H
2091+#ifndef SCALESTACK_EVENT_TEST_HANDLER_SERVICE_PROVIDER_H
2092+#define SCALESTACK_EVENT_TEST_HANDLER_SERVICE_PROVIDER_H
2093
2094 #include <scalestack/common/macros.h>
2095-#include <scalestack/event/service_provider.h>
2096+#include <scalestack/event/handler_service.h>
2097
2098 namespace scalestack
2099 {
2100@@ -28,28 +28,29 @@
2101
2102 class handler_provider;
2103
2104-class SCALESTACK_API service_provider: public event::service_provider
2105+class SCALESTACK_API handler_service_provider: public event::handler_service_provider
2106 {
2107 public:
2108
2109- service_provider(kernel::module& creator);
2110-
2111- ~service_provider();
2112-
2113- /**
2114- * See event::service::add_handler().
2115- */
2116- void add_handler(event::handler* new_handler);
2117+ handler_service_provider(kernel::module& module,
2118+ event::handler_service& handler_service);
2119+
2120+ ~handler_service_provider();
2121+
2122+ /**
2123+ * See event::handler_service::add_handler().
2124+ */
2125+ void add_handler(event::handler* handler);
2126+
2127+ /**
2128+ * See event::handler_service::shutdown().
2129+ */
2130+ void shutdown(void);
2131
2132 /**
2133 * Queue a handler provider to be removed.
2134 */
2135- void queue_to_remove(handler_provider* old_handler_provider);
2136-
2137- /**
2138- * Remove handler providers in remove queue.
2139- */
2140- void check_remove_queue(void);
2141+ void queue_to_remove(handler_provider* handler_provider);
2142
2143 private:
2144
2145@@ -57,19 +58,19 @@
2146 * Don't allow copying of objects.
2147 */
2148 SCALESTACK_LOCAL
2149- service_provider(const service_provider&);
2150+ handler_service_provider(const handler_service_provider&);
2151
2152 /**
2153 * Don't allow assignment of objects.
2154 */
2155 SCALESTACK_LOCAL
2156- service_provider& operator=(const service_provider&);
2157+ handler_service_provider& operator=(const handler_service_provider&);
2158
2159- handler_provider* _old_handler_provider;
2160+ handler_provider* _handler_provider;
2161 };
2162
2163 } /* namespace test */
2164 } /* namespace event */
2165 } /* namespace scalestack */
2166
2167-#endif /* SCALESTACK_EVENT_TEST_SERVICE_PROVIDER_H */
2168+#endif /* SCALESTACK_EVENT_TEST_HANDLER_SERVICE_PROVIDER_H */
2169
2170=== modified file 'scalestack/event/test/plugin.ini'
2171--- scalestack/event/test/plugin.ini 2010-06-03 04:51:37 +0000
2172+++ scalestack/event/test/plugin.ini 2010-06-16 19:32:28 +0000
2173@@ -5,7 +5,7 @@
2174 author=Eric Day <eday@oddments.org>
2175 license=BSD
2176 install=no
2177-sources=handler.cc handler_provider.cc run.cc service.cc service_provider.cc test.cc
2178-headers=handler.h handler_provider.h service.h service_provider.h
2179+sources=handler.cc handler_provider.cc handler_service.cc handler_service_provider.cc service.cc test.cc
2180+headers=handler.h handler_provider.h handler_service.h handler_service_provider.h service.h
2181 dependencies=event
2182 tests=run
2183
2184=== modified file 'scalestack/event/test/run.cc'
2185--- scalestack/event/test/run.cc 2010-06-03 04:51:37 +0000
2186+++ scalestack/event/test/run.cc 2010-06-16 19:32:28 +0000
2187@@ -18,7 +18,6 @@
2188 TEST_SUITE_BEGIN
2189
2190 TEST_BEGIN(test_event)
2191- core.get_or_add_module("event");
2192 core.get_or_add_module("event::test");
2193 core.run();
2194 TEST_END
2195
2196=== added file 'scalestack/event/test/service.cc'
2197--- scalestack/event/test/service.cc 1970-01-01 00:00:00 +0000
2198+++ scalestack/event/test/service.cc 2010-06-16 19:32:28 +0000
2199@@ -0,0 +1,57 @@
2200+/*
2201+ * Scale Stack
2202+ *
2203+ * Copyright (C) 2010 Eric Day (eday@oddments.org)
2204+ * All rights reserved.
2205+ *
2206+ * Use and distribution licensed under the BSD license. See the
2207+ * COPYING file in the root project directory for full text.
2208+ */
2209+
2210+/**
2211+ * @file
2212+ * @brief Event Test Service Definitions
2213+ */
2214+
2215+#include "config.h"
2216+
2217+#include <scalestack/event/test/handler_service_provider.h>
2218+#include <scalestack/event/test/service.h>
2219+
2220+namespace scalestack
2221+{
2222+namespace event
2223+{
2224+namespace test
2225+{
2226+
2227+/*
2228+ * Public methods.
2229+ */
2230+
2231+service::service(kernel::module& module):
2232+ event::service(module)
2233+{
2234+}
2235+
2236+service::~service()
2237+{
2238+}
2239+
2240+/*
2241+ * Private methods.
2242+ */
2243+
2244+event::handler_service_provider& service::_add_handler_service(event::handler_service& handler_service)
2245+{
2246+ return *(new handler_service_provider(_module, handler_service));
2247+}
2248+
2249+void service::_remove_handler_service(event::handler_service_provider& handler_service_provider)
2250+{
2251+ delete &handler_service_provider;
2252+}
2253+
2254+} /* namespace test */
2255+} /* namespace event */
2256+} /* namespace scalestack */
2257
2258=== added file 'scalestack/event/test/service.h'
2259--- scalestack/event/test/service.h 1970-01-01 00:00:00 +0000
2260+++ scalestack/event/test/service.h 2010-06-16 19:32:28 +0000
2261@@ -0,0 +1,66 @@
2262+/*
2263+ * Scale Stack
2264+ *
2265+ * Copyright (C) 2010 Eric Day (eday@oddments.org)
2266+ * All rights reserved.
2267+ *
2268+ * Use and distribution licensed under the BSD license. See the
2269+ * COPYING file in the root project directory for full text.
2270+ */
2271+
2272+/**
2273+ * @file
2274+ * @brief Event Test Service Declarations
2275+ */
2276+
2277+#ifndef SCALESTACK_EVENT_TEST_SERVICE_H
2278+#define SCALESTACK_EVENT_TEST_SERVICE_H
2279+
2280+#include <scalestack/common/macros.h>
2281+#include <scalestack/event/service.h>
2282+
2283+namespace scalestack
2284+{
2285+namespace event
2286+{
2287+namespace test
2288+{
2289+
2290+class SCALESTACK_API service: public event::service
2291+{
2292+public:
2293+
2294+ service(kernel::module& module);
2295+
2296+ virtual ~service();
2297+
2298+private:
2299+
2300+ /**
2301+ * Don't allow copying of objects.
2302+ */
2303+ SCALESTACK_LOCAL
2304+ service(const service&);
2305+
2306+ /**
2307+ * Don't allow assignment of objects.
2308+ */
2309+ SCALESTACK_LOCAL
2310+ service& operator=(const service&);
2311+
2312+ /**
2313+ * See event::service::_add_handler_service().
2314+ */
2315+ event::handler_service_provider& _add_handler_service(event::handler_service& handler_service);
2316+
2317+ /**
2318+ * See event::service::_remove_handler_service().
2319+ */
2320+ void _remove_handler_service(event::handler_service_provider& handler_service_provider);
2321+};
2322+
2323+} /* namespace test */
2324+} /* namespace event */
2325+} /* namespace scalestack */
2326+
2327+#endif /* SCALESTACK_EVENT_TEST_SERVICE_H */
2328
2329=== modified file 'scalestack/event/test/test.cc'
2330--- scalestack/event/test/test.cc 2010-06-03 04:51:37 +0000
2331+++ scalestack/event/test/test.cc 2010-06-16 19:32:28 +0000
2332@@ -16,40 +16,36 @@
2333 #include "config.h"
2334
2335 #include <scalestack/event/test/handler.h>
2336+#include <scalestack/event/test/handler_service.h>
2337 #include <scalestack/event/test/service.h>
2338-#include <scalestack/event/test/service_provider.h>
2339 #include <scalestack/kernel/core.h>
2340 #include <scalestack/kernel/module.h>
2341
2342 using namespace std;
2343 using namespace scalestack;
2344
2345-static void start(kernel::module& current)
2346-{
2347- event::test::service_provider* test_service_provider = new event::test::service_provider(current);
2348- current.get_core().add_service("event", test_service_provider);
2349-
2350- event::test::service* test_service = new event::test::service(current);
2351- current.get_core().add_service("event::test", test_service);
2352-}
2353-
2354-static void stop(kernel::module& current)
2355-{
2356- delete current.get_core().remove_service("event::test");
2357- delete current.get_core().remove_service("event");
2358-}
2359-
2360-static void run(kernel::module& current)
2361-{
2362- event::test::service& test_service = static_cast<event::test::service&>(current.get_core().get_service("event::test"));
2363-
2364- test_service.add_handler(new event::test::handler(test_service));
2365-
2366- event::test::service_provider& test_service_provider = static_cast<event::test::service_provider&>(current.get_core().get_service("event"));
2367-
2368- test_service_provider.check_remove_queue();
2369-
2370- current.get_core().shutdown();
2371+static void start(kernel::module& module)
2372+{
2373+ event::test::service* test_service = new event::test::service(module);
2374+ module.get_core().add_service("event", test_service);
2375+
2376+ event::test::handler_service* test_handler_service = new event::test::handler_service(module);
2377+ module.get_core().add_service("event::test", test_handler_service);
2378+}
2379+
2380+static void stop(kernel::module& module)
2381+{
2382+ delete module.get_core().remove_service("event::test");
2383+ delete module.get_core().remove_service("event");
2384+}
2385+
2386+static void run(kernel::module& module)
2387+{
2388+ event::test::handler_service& test_handler_service = static_cast<event::test::handler_service&>(module.get_core().get_service("event::test"));
2389+
2390+ test_handler_service.add_handler(new event::test::handler(test_handler_service));
2391+
2392+ module.get_core().shutdown();
2393 }
2394
2395 SCALESTACK_KERNEL_MODULE(NULL, start, stop, run, NULL);
2396
2397=== modified file 'scalestack/kernel/core.cc'
2398--- scalestack/kernel/core.cc 2010-06-03 04:51:37 +0000
2399+++ scalestack/kernel/core.cc 2010-06-16 19:32:28 +0000
2400@@ -38,14 +38,13 @@
2401 namespace kernel
2402 {
2403
2404-/*
2405+/**
2406 * This is provided for convenience for applications that only use a single
2407 * Core instance per process. This needs to be 'extern "C"' and not just
2408 * static to make SunCC happy.
2409 */
2410-
2411-static scalestack::kernel::core* global_kernel_core = NULL;
2412 extern "C" void global_signal_handler(int signal_number);
2413+static core* global_kernel_core = NULL;
2414 extern "C" void global_signal_handler(int signal_number)
2415 {
2416 global_kernel_core->handle_signal(signal_number);
2417@@ -96,11 +95,11 @@
2418 {
2419 log_error(_("Services still exist"));
2420
2421- for (map<string, service*>::const_iterator leftover = _services.begin();
2422- leftover != _services.end();
2423- ++leftover)
2424+ for (services::const_iterator service = _services.begin();
2425+ service != _services.end();
2426+ ++service)
2427 {
2428- log_error(" %s", leftover->first.c_str());
2429+ log_error(" %s", service->first.c_str());
2430 }
2431 }
2432
2433@@ -109,18 +108,20 @@
2434 {
2435 log_error(_("Logs still exist"));
2436
2437- for (map<string, log*>::const_iterator leftover = _logs.begin();
2438- leftover != _logs.end();
2439- ++leftover)
2440+ for (logs::const_iterator log = _logs.begin();
2441+ log != _logs.end();
2442+ ++log)
2443 {
2444- log_error(" %s", leftover->first.c_str());
2445+ log_error(" %s", log->first.c_str());
2446 }
2447 }
2448
2449 log_info(_("Destructed core object"));
2450
2451 delete remove_log("console");
2452- global_kernel_core = NULL;
2453+
2454+ if (global_kernel_core == this)
2455+ global_kernel_core = NULL;
2456 }
2457
2458 void core::parse_arguments(int argument_count, const char** arguments)
2459@@ -142,7 +143,7 @@
2460
2461 /* Check for verbose flags. */
2462 if (argument.find_first_not_of("v") == string::npos)
2463- _log_threshold += argument.size();
2464+ _threshold += argument.size();
2465 }
2466
2467 for (int current = 0; current < argument_count; current++)
2468@@ -231,7 +232,7 @@
2469 }
2470
2471 /* Module name and value given, add an alias for the module name. */
2472- map<string, string>::iterator alias;
2473+ aliases::iterator alias;
2474 for (alias = _aliases.begin(); alias != _aliases.end(); ++alias)
2475 {
2476 if (!strcasecmp(alias->first.c_str(), module_name.c_str()))
2477@@ -251,11 +252,6 @@
2478 get_or_add_module(module_name)._set_option_value(option_name, value);
2479 }
2480
2481-void core::set_log_threshold(size_t log_threshold)
2482-{
2483- _log_threshold = log_threshold;
2484-}
2485-
2486 void core::set_signal_handlers(void)
2487 {
2488 if (global_kernel_core != NULL)
2489@@ -272,28 +268,28 @@
2490 if (sigemptyset(&signal_action.sa_mask) == -1 ||
2491 sigaction(SIGPIPE, &signal_action, 0) == -1)
2492 {
2493- log_fatal(_("Could not set SIGPIPE handler: %s"), strerror(errno));
2494+ log_fatal(_("Could not set SIGPIPE handler: %s:%d"), strerror(errno), errno);
2495 }
2496
2497 signal_action.sa_handler = global_signal_handler;
2498
2499 if (sigaction(SIGHUP, &signal_action, 0) == -1)
2500- log_fatal(_("Could not set SIGHUP handler: %s"), strerror(errno));
2501+ log_fatal(_("Could not set SIGHUP handler: %s:%d"), strerror(errno), errno);
2502
2503 if (sigaction(SIGINT, &signal_action, 0) == -1)
2504- log_fatal(_("Could not set SIGINT handler: %s"), strerror(errno));
2505+ log_fatal(_("Could not set SIGINT handler: %s:%d"), strerror(errno), errno);
2506
2507 if (sigaction(SIGQUIT, &signal_action, 0) == -1)
2508- log_fatal(_("Could not set SIGQUIT handler: %s"), strerror(errno));
2509+ log_fatal(_("Could not set SIGQUIT handler: %s:%d"), strerror(errno), errno);
2510
2511 if (sigaction(SIGTERM, &signal_action, 0) == -1)
2512- log_fatal(_("Could not set SIGTERM handler: %s"), strerror(errno));
2513+ log_fatal(_("Could not set SIGTERM handler: %s:%d"), strerror(errno), errno);
2514
2515 if (sigaction(SIGUSR1, &signal_action, 0) == -1)
2516- log_fatal(_("Could not set SIGUSR1 handler: %s"), strerror(errno));
2517+ log_fatal(_("Could not set SIGUSR1 handler: %s:%d"), strerror(errno), errno);
2518
2519 if (sigaction(SIGUSR2, &signal_action, 0) == -1)
2520- log_fatal(_("Could not set SIGUSR2 handler: %s"), strerror(errno));
2521+ log_fatal(_("Could not set SIGUSR2 handler: %s:%d"), strerror(errno), errno);
2522 }
2523
2524 void core::handle_signal(int signal_number)
2525@@ -312,33 +308,33 @@
2526 {
2527 const string& alias = _get_alias(name);
2528
2529- module* current = _get_module(alias);
2530- if (current != NULL)
2531- return *current;
2532+ module* module = _get_module(alias);
2533+ if (module != NULL)
2534+ return *module;
2535
2536- current = new module(*this, alias, _log_threshold);
2537+ module = new kernel::module(*this, alias, _threshold);
2538 try
2539 {
2540- _add_modules.push_back(current);
2541+ _add_modules.push_back(module);
2542 }
2543 catch (exception&)
2544 {
2545- delete current;
2546+ delete module;
2547 throw;
2548 }
2549
2550- return *current;
2551+ return *module;
2552 }
2553
2554 module& core::get_module(const std::string& name) const
2555 {
2556 const string& alias = _get_alias(name);
2557
2558- module* current = _get_module(alias);
2559- if (current == NULL)
2560+ module* module = _get_module(alias);
2561+ if (module == NULL)
2562 log_fatal(_("Could not find module: %s"), alias.c_str());
2563
2564- return *current;
2565+ return *module;
2566 }
2567
2568 size_t core::get_module_count(void) const
2569@@ -367,10 +363,10 @@
2570 return *(_module_iterator++);
2571 }
2572
2573-void core::add_service(const std::string& name, service* new_service)
2574+void core::add_service(const std::string& name, service* service)
2575 {
2576- pair<map<string, service*>::iterator, bool> result;
2577- result = _services.insert(pair<string, service*>(name, new_service));
2578+ pair<services::iterator, bool> result;
2579+ result = _services.insert(pair<string, kernel::service*>(name, service));
2580 if (result.second == false)
2581 log_fatal(_("Service already exists: %s"), name.c_str());
2582
2583@@ -379,19 +375,19 @@
2584
2585 service* core::remove_service(const std::string& name)
2586 {
2587- map<string, service*>::iterator result = _services.find(name);
2588+ services::iterator result = _services.find(name);
2589 if (result == _services.end())
2590 log_fatal(_("Could not find service: %s"), name.c_str());
2591
2592- service* removed = result->second;
2593+ service* service = result->second;
2594 _services.erase(result);
2595 log_info(_("Removed service: %s"), name.c_str());
2596- return removed;
2597+ return service;
2598 }
2599
2600 service& core::get_service(const std::string& name) const
2601 {
2602- map<string, service*>::const_iterator result = _services.find(name);
2603+ services::const_iterator result = _services.find(name);
2604 if (result == _services.end())
2605 log_fatal(_("Could not find service: %s"), name.c_str());
2606
2607@@ -403,10 +399,10 @@
2608 return _services.size();
2609 }
2610
2611-void core::add_log(const std::string& name, log* new_log)
2612+void core::add_log(const std::string& name, log* log)
2613 {
2614- pair<map<string, log*>::iterator, bool> result;
2615- result = _logs.insert(pair<string, log*>(name, new_log));
2616+ pair<logs::iterator, bool> result;
2617+ result = _logs.insert(pair<string, kernel::log*>(name, log));
2618 if (result.second == false)
2619 log_fatal(_("Log already exists: %s"), name.c_str());
2620
2621@@ -415,19 +411,19 @@
2622
2623 log* core::remove_log(const std::string& name)
2624 {
2625- map<string, log*>::iterator result = _logs.find(name);
2626+ logs::iterator result = _logs.find(name);
2627 if (result == _logs.end())
2628 log_fatal(_("Could not find log: %s"), name.c_str());
2629
2630- log* removed = result->second;
2631+ log* log = result->second;
2632 _logs.erase(result);
2633 log_info(_("Removed log: %s"), name.c_str());
2634- return removed;
2635+ return log;
2636 }
2637
2638 log& core::get_log(const std::string& name) const
2639 {
2640- map<string, log*>::const_iterator result = _logs.find(name);
2641+ logs::const_iterator result = _logs.find(name);
2642 if (result == _logs.end())
2643 log_fatal(_("Could not find log: %s"), name.c_str());
2644
2645@@ -496,7 +492,7 @@
2646
2647 const string& core::_get_alias(const std::string& name) const
2648 {
2649- for (map<string, string>::const_iterator alias = _aliases.begin();
2650+ for (aliases::const_iterator alias = _aliases.begin();
2651 alias != _aliases.end();
2652 ++alias)
2653 {
2654@@ -514,20 +510,20 @@
2655 * bind2nd, and that has the reference-to-reference problem with some
2656 * implementations when used with methods that take a reference.
2657 */
2658- for (vector<module*>::const_iterator current = _modules.begin();
2659- current != _modules.end();
2660- ++current)
2661+ for (modules::const_iterator module = _modules.begin();
2662+ module != _modules.end();
2663+ ++module)
2664 {
2665- if (!strcasecmp((*current)->get_name().c_str(), name.c_str()))
2666- return *current;
2667+ if (!strcasecmp((*module)->get_name().c_str(), name.c_str()))
2668+ return *module;
2669 }
2670
2671- for (vector<module*>::const_iterator current = _add_modules.begin();
2672- current != _add_modules.end();
2673- ++current)
2674+ for (modules::const_iterator module = _add_modules.begin();
2675+ module != _add_modules.end();
2676+ ++module)
2677 {
2678- if (!strcasecmp((*current)->get_name().c_str(), name.c_str()))
2679- return *current;
2680+ if (!strcasecmp((*module)->get_name().c_str(), name.c_str()))
2681+ return *module;
2682 }
2683
2684 return NULL;
2685@@ -555,11 +551,11 @@
2686 char message[SCALESTACK_MAX_MESSAGE_SIZE];
2687 vsnprintf(message, SCALESTACK_MAX_MESSAGE_SIZE, format, arguments);
2688
2689- for (map<string, log*>::const_iterator current = _logs.begin();
2690- current != _logs.end();
2691- ++current)
2692+ for (logs::const_iterator log = _logs.begin();
2693+ log != _logs.end();
2694+ ++log)
2695 {
2696- current->second->write_log(log_level, context, message);
2697+ log->second->write_log(log_level, context, message);
2698 }
2699
2700 if (log_level == log::LEVEL_FATAL)
2701@@ -569,7 +565,7 @@
2702 void core::_print_help(void)
2703 {
2704 cout << endl << PACKAGE_STRING << endl << _("\n\
2705-Kernel\n\
2706+kernel\n\
2707 v - Increase verbosity level.\n\
2708 h, help - Display this help message.\n\
2709 p, path=PATH - Add path to module search list.\n\
2710@@ -579,28 +575,28 @@
2711 for_each(_modules.begin(), _modules.end(), mem_fun(&module::_print_help));
2712
2713 cout << _("\n\
2714-Modules can be loaded by simply giving the module name as an\n\
2715-option. For example, if you run 'scalestack echo', this will load\n\
2716-the echo module and any dependencies.\n\
2717+Modules can be loaded by simply giving the module name as an option. For\n\
2718+example, if you run 'scalestack echo::server::tcp', this will load the TCP\n\
2719+echo server module and any dependencies.\n\
2720 \n\
2721 Module aliases may be specified using the format:\n\
2722 \n\
2723 module_alias=module_name\n\
2724 \n\
2725-For example, if you run 'scalestack event_service=event_libevent', the\n\
2726-module 'event_libevent' will be loaded if any other modules depend\n\
2727-on 'event_service'. This allows a generic service name to be listed\n\
2728-as a dependency when there are multiple modules that could provide\n\
2729-that service.\n\
2730+For example, if you run 'scalestack event::service=event::libevent', the\n\
2731+module 'event::libevent' will be loaded if any other modules depend on\n\
2732+'event::service'. This allows a generic service name to be listed as a\n\
2733+dependency when there are multiple modules that can provide that service.\n\
2734 \n\
2735-module options are specified using the format\n\
2736+Module options are specified using the format\n\
2737 \n\
2738 module_name.option[=value]\n\
2739 \n\
2740-For example, if you run 'scalestack echo_server.ports=4321', the\n\
2741-echo_server module will be loaded and will be run on port '4321'. For\n\
2742-boolean options, you can specify 'false', 'f', 'no', 'n', or '0' to\n\
2743-mean false using any case. Everything else will be treated as true.\n\
2744+For example, if you run 'scalestack echo::server::tcp.ports=4321', the\n\
2745+echo::server::tcp module will be loaded and will be run on port '4321'. For\n\
2746+boolean options, you can specify 'false', 'f', 'no', 'n', or '0' to mean\n\
2747+false using any mix of upper and lower case. Everything else will be treated\n\
2748+as true.\n\
2749 \n");
2750 }
2751
2752
2753=== modified file 'scalestack/kernel/core.h'
2754--- scalestack/kernel/core.h 2010-06-03 04:51:37 +0000
2755+++ scalestack/kernel/core.h 2010-06-16 19:32:28 +0000
2756@@ -55,6 +55,9 @@
2757 */
2758 ~core();
2759
2760+ /* This is here to make the base method public. */
2761+ using log_message::set_threshold;
2762+
2763 /**
2764 * Parse arguments, most likely from the main() function arguments.
2765 *
2766@@ -80,14 +83,6 @@
2767 const std::string& value);
2768
2769 /**
2770- * Set the log threshold for kernel logs. This is also set by passing 'v'
2771- * or 'verbose' arguments into parse_arguments().
2772- *
2773- * @param[in] log_threshold The new log threshold to set.
2774- */
2775- void set_log_threshold(size_t log_threshold);
2776-
2777- /**
2778 * Set common signal handlers. Calling applications can either use this for
2779 * convenience or handle their own signals. SIGPIPE is set to be ignored,
2780 * and the following signals are set to call the given handler function:
2781@@ -159,9 +154,9 @@
2782 * already exists, this will fail and return false.
2783 *
2784 * @param[in] name Name of the service to add.
2785- * @param[in] new_service The service object to add.
2786+ * @param[in] service The service object to add.
2787 */
2788- void add_service(const std::string& name, service* new_service);
2789+ void add_service(const std::string& name, service* service);
2790
2791 /**
2792 * Remove a service object for the given name.
2793@@ -189,9 +184,9 @@
2794 * exists, this will fail and return false.
2795 *
2796 * @param[in] name Name of the log to add.
2797- * @param[in] new_log The log object to add.
2798+ * @param[in] log The log object to add.
2799 */
2800- void add_log(const std::string& name, log* new_log);
2801+ void add_log(const std::string& name, log* log);
2802
2803 /**
2804 * Remove a log object for the given name.
2805@@ -302,17 +297,23 @@
2806 SCALESTACK_LOCAL
2807 void _print_help(void);
2808
2809+ typedef std::vector<std::string> paths;
2810+ typedef std::vector<module*> modules;
2811+ typedef std::map<std::string, std::string> aliases;
2812+ typedef std::map<std::string, service*> services;
2813+ typedef std::map<std::string, log*> logs;
2814+
2815 bool _need_help;
2816 bool _shutdown_request;
2817 bool _iterator_on_modules;
2818 common::notification _run_notification;
2819- std::vector<std::string> _paths;
2820- std::vector<module*> _modules;
2821- std::vector<module*> _add_modules;
2822- std::vector<module*>::iterator _module_iterator;
2823- std::map<std::string, std::string> _aliases;
2824- std::map<std::string, service*> _services;
2825- std::map<std::string, log*> _logs;
2826+ paths _paths;
2827+ modules _modules;
2828+ modules _add_modules;
2829+ modules::iterator _module_iterator;
2830+ aliases _aliases;
2831+ services _services;
2832+ logs _logs;
2833 };
2834
2835 } /* namespace kernel */
2836
2837=== modified file 'scalestack/kernel/log.h'
2838--- scalestack/kernel/log.h 2010-06-03 04:51:37 +0000
2839+++ scalestack/kernel/log.h 2010-06-16 19:32:28 +0000
2840@@ -53,14 +53,14 @@
2841 * @param[in] context Context string for this message.
2842 * @param[in] message Message to log.
2843 */
2844- virtual void write_log(level log_level,
2845+ virtual void write_log(log::level log_level,
2846 const char* context,
2847 const char* message) = 0;
2848
2849 /**
2850 * Get the string representation for a givel log level.
2851 */
2852- const char* get_level_string(level log_level);
2853+ const char* get_level_string(log::level log_level);
2854
2855 private:
2856
2857@@ -87,7 +87,7 @@
2858 {
2859 }
2860
2861-inline const char* log::get_level_string(level log_level)
2862+inline const char* log::get_level_string(log::level log_level)
2863 {
2864 switch (log_level)
2865 {
2866
2867=== modified file 'scalestack/kernel/log_console.h'
2868--- scalestack/kernel/log_console.h 2010-06-03 04:51:37 +0000
2869+++ scalestack/kernel/log_console.h 2010-06-16 19:32:28 +0000
2870@@ -40,7 +40,9 @@
2871 * @param[in] context Context string for this message.
2872 * @param[in] message Message to log.
2873 */
2874- void write_log(level log_level, const char* context, const char* message);
2875+ void write_log(log::level log_level,
2876+ const char* context,
2877+ const char* message);
2878
2879 private:
2880
2881
2882=== modified file 'scalestack/kernel/log_message.h'
2883--- scalestack/kernel/log_message.h 2010-06-03 04:51:37 +0000
2884+++ scalestack/kernel/log_message.h 2010-06-16 19:32:28 +0000
2885@@ -33,11 +33,18 @@
2886 {
2887 public:
2888
2889- log_message(size_t log_threshold);
2890+ log_message(size_t threshold);
2891
2892 virtual ~log_message();
2893
2894 /**
2895+ * Set the threshold for logging messages.
2896+ *
2897+ * @param[in] threshold The new log threshold to set.
2898+ */
2899+ void set_threshold(size_t threshold);
2900+
2901+ /**
2902 * Log a fatal message with the formatted string if log threshold is met.
2903 *
2904 * @param[in] format Message format string.
2905@@ -74,7 +81,7 @@
2906
2907 protected:
2908
2909- size_t _log_threshold;
2910+ size_t _threshold;
2911
2912 private:
2913
2914@@ -114,8 +121,8 @@
2915 * Public methods.
2916 */
2917
2918-inline log_message::log_message(size_t log_threshold):
2919- _log_threshold(log_threshold)
2920+inline log_message::log_message(size_t threshold):
2921+ _threshold(threshold)
2922 {
2923 }
2924
2925@@ -123,6 +130,11 @@
2926 {
2927 }
2928
2929+inline void log_message::set_threshold(size_t threshold)
2930+{
2931+ _threshold = threshold;
2932+}
2933+
2934 inline void log_message::log_fatal(const char* format, ...) const
2935 {
2936 std::va_list arguments;
2937@@ -135,7 +147,7 @@
2938 */
2939 try
2940 {
2941- if (_log_threshold >= 1)
2942+ if (_threshold >= 1)
2943 _log_message(log::LEVEL_FATAL, format, arguments);
2944 else
2945 _set_fatal_message(format, arguments);
2946@@ -151,7 +163,7 @@
2947
2948 inline void log_message::log_error(const char* format, ...) const
2949 {
2950- if (_log_threshold >= 1)
2951+ if (_threshold >= 1)
2952 {
2953 std::va_list arguments;
2954 va_start(arguments, format);
2955@@ -162,7 +174,7 @@
2956
2957 inline void log_message::log_notice(const char* format, ...) const
2958 {
2959- if (_log_threshold >= 1)
2960+ if (_threshold >= 1)
2961 {
2962 std::va_list arguments;
2963 va_start(arguments, format);
2964@@ -173,7 +185,7 @@
2965
2966 inline void log_message::log_info(const char* format, ...) const
2967 {
2968- if (_log_threshold >= 2)
2969+ if (_threshold >= 2)
2970 {
2971 std::va_list arguments;
2972 va_start(arguments, format);
2973@@ -184,7 +196,7 @@
2974
2975 inline void log_message::log_debug(const char* format, ...) const
2976 {
2977- if (_log_threshold >= 3)
2978+ if (_threshold >= 3)
2979 {
2980 std::va_list arguments;
2981 va_start(arguments, format);
2982
2983=== modified file 'scalestack/kernel/module.cc'
2984--- scalestack/kernel/module.cc 2010-06-03 04:51:37 +0000
2985+++ scalestack/kernel/module.cc 2010-06-16 19:32:28 +0000
2986@@ -143,25 +143,25 @@
2987 const std::string& value_name,
2988 const std::string& default_value)
2989 {
2990- option& current = _get_or_add_option(name);
2991- if (current.is_valid())
2992+ option& option = _get_or_add_option(name);
2993+ if (option.is_valid())
2994 log_fatal(_("Duplicate option added: %s"), name.c_str());
2995
2996- current._set_help(help);
2997- current._set_value_name(value_name);
2998- current._set_default_value(default_value);
2999- current._set_value(default_value, false);
3000- current._set_valid(true);
3001- return current;
3002+ option._set_help(help);
3003+ option._set_value_name(value_name);
3004+ option._set_default_value(default_value);
3005+ option._set_value(default_value, false);
3006+ option._set_valid(true);
3007+ return option;
3008 }
3009
3010 option& module::get_option(const std::string& name) const
3011 {
3012- option* current = _get_option(name);
3013- if (current == NULL)
3014+ option* option = _get_option(name);
3015+ if (option == NULL)
3016 log_fatal(_("Could not find option: %s"), name.c_str());
3017
3018- return *current;
3019+ return *option;
3020 }
3021
3022 size_t module::get_option_count(void) const
3023@@ -187,13 +187,13 @@
3024 * Private methods.
3025 */
3026
3027-module::module(core& creator, const std::string& name, size_t log_threshold):
3028- log_message(log_threshold),
3029+module::module(core& core, const std::string& name, size_t threshold):
3030+ log_message(threshold),
3031 _is_loading(false),
3032 _is_started(false),
3033 _need_run(true),
3034 _need_reconfigure(true),
3035- _core(creator),
3036+ _core(core),
3037 _handle(),
3038 _definition(),
3039 _name(name),
3040@@ -263,7 +263,7 @@
3041 filename.push_back(static_cast<char>(tolower(*c)));
3042 }
3043
3044- vector<string>::const_iterator path;
3045+ core::paths::const_iterator path;
3046 for (path = _core._paths.begin(); path != _core._paths.end(); ++path)
3047 {
3048 _pathname = *(path) + "/lib" + filename + "_module." + SCALESTACK_MODULE_EXT;
3049@@ -274,8 +274,8 @@
3050 if (stat_return == 0)
3051 break;
3052 else if (stat_return == -1 && errno != ENOENT)
3053- log_fatal(_("Could not stat() pathname: %s (%s)"),
3054- _pathname.c_str(), strerror(errno));
3055+ log_fatal(_("Could not stat() pathname: %s (%s:%d)"),
3056+ _pathname.c_str(), strerror(errno), errno);
3057 }
3058
3059 if (path == _core._paths.end())
3060@@ -405,12 +405,12 @@
3061 * bind2nd, and that has the reference-to-reference problem with some
3062 * implementations when used with methods that take a reference.
3063 */
3064- for (vector<option*>::const_iterator current = _options.begin();
3065- current != _options.end();
3066- ++current)
3067+ for (options::const_iterator option = _options.begin();
3068+ option != _options.end();
3069+ ++option)
3070 {
3071- if (!strcasecmp((*current)->get_name().c_str(), name.c_str()))
3072- return *current;
3073+ if (!strcasecmp((*option)->get_name().c_str(), name.c_str()))
3074+ return *option;
3075 }
3076
3077 return NULL;
3078@@ -418,37 +418,37 @@
3079
3080 option& module::_get_or_add_option(const std::string& name)
3081 {
3082- option* current = _get_option(name);
3083- if (current != NULL)
3084- return *current;
3085+ option* option = _get_option(name);
3086+ if (option != NULL)
3087+ return *option;
3088
3089- current = new option(*this, name);
3090+ option = new kernel::option(*this, name);
3091 try
3092 {
3093- _options.push_back(current);
3094+ _options.push_back(option);
3095 }
3096 catch (exception&)
3097 {
3098- delete current;
3099+ delete option;
3100 throw;
3101 }
3102
3103- return *current;
3104+ return *option;
3105 }
3106
3107 void module::_set_option_value(const std::string& name, const std::string& value)
3108 {
3109- option& current = _get_or_add_option(name);
3110- current._set_value(value, true);
3111+ option& option = _get_or_add_option(name);
3112+ option._set_value(value, true);
3113 }
3114
3115 void module::_check_options(void) const
3116 {
3117- vector<option*>::const_iterator current = find_if(_options.begin(),
3118- _options.end(),
3119- not1(mem_fun(&option::is_valid)));
3120- if (current != _options.end())
3121- log_fatal(_("Invalid option: %s"), (*current)->get_name().c_str());
3122+ options::const_iterator option = find_if(_options.begin(),
3123+ _options.end(),
3124+ not1(mem_fun(&option::is_valid)));
3125+ if (option != _options.end())
3126+ log_fatal(_("Invalid option: %s"), (*option)->get_name().c_str());
3127 }
3128
3129 void module::_set_fatal_message(const char* format, std::va_list arguments) const
3130
3131=== modified file 'scalestack/kernel/module.h'
3132--- scalestack/kernel/module.h 2010-06-03 04:51:37 +0000
3133+++ scalestack/kernel/module.h 2010-06-16 19:32:28 +0000
3134@@ -37,8 +37,6 @@
3135 */
3136 class SCALESTACK_API module: public log_message
3137 {
3138- friend class core;
3139-
3140 public:
3141
3142 /**
3143@@ -64,6 +62,9 @@
3144
3145 ~module();
3146
3147+ /* This is here to make the base method public. */
3148+ using log_message::set_threshold;
3149+
3150 /**
3151 * Get the Core object that this module belongs to.
3152 */
3153@@ -202,12 +203,12 @@
3154 * Construct a module instance. This is private because only Core, which
3155 * is listed as a friend, can construct modules.
3156 *
3157- * @param[in] creator Core that created this module.
3158+ * @param[in] core Core that created this module.
3159 * @param[in] name Name of module to create.
3160- * @param[in] log_threshold Logging threshold.
3161+ * @param[in] threshold Logging threshold.
3162 */
3163 SCALESTACK_LOCAL
3164- module(core& creator, const std::string& name, size_t log_threshold);
3165+ module(core& core, const std::string& name, size_t threshold);
3166
3167 /**
3168 * Don't allow copying of objects.
3169@@ -344,6 +345,9 @@
3170 SCALESTACK_LOCAL
3171 void _print_help(void);
3172
3173+ typedef std::vector<module*> modules;
3174+ typedef std::vector<option*> options;
3175+
3176 bool _is_loading;
3177 bool _is_started;
3178 bool _need_run;
3179@@ -358,12 +362,14 @@
3180 std::string _title;
3181 std::string _license;
3182 std::string _dependencies;
3183- std::vector<module*> _parents;
3184- std::vector<module*>::iterator _parent_iterator;
3185- std::vector<module*> _children;
3186- std::vector<module*>::iterator _child_iterator;
3187- std::vector<option*> _options;
3188- std::vector<option*>::iterator _option_iterator;
3189+ modules _parents;
3190+ modules::iterator _parent_iterator;
3191+ modules _children;
3192+ modules::iterator _child_iterator;
3193+ options _options;
3194+ options::iterator _option_iterator;
3195+
3196+ friend class core;
3197 };
3198
3199 } /* namespace kernel */
3200
3201=== modified file 'scalestack/kernel/option.cc'
3202--- scalestack/kernel/option.cc 2010-06-03 04:51:37 +0000
3203+++ scalestack/kernel/option.cc 2010-06-16 19:32:28 +0000
3204@@ -137,10 +137,10 @@
3205 * Private methods.
3206 */
3207
3208-option::option(module& creator, const std::string& name):
3209+option::option(module& module, const std::string& name):
3210 _is_valid(false),
3211 _is_set(false),
3212- _module(creator),
3213+ _module(module),
3214 _name(name),
3215 _help(),
3216 _value_name(),
3217
3218=== modified file 'scalestack/kernel/option.h'
3219--- scalestack/kernel/option.h 2010-06-03 20:51:05 +0000
3220+++ scalestack/kernel/option.h 2010-06-16 19:32:28 +0000
3221@@ -35,8 +35,6 @@
3222 */
3223 class SCALESTACK_API option
3224 {
3225- friend class module;
3226-
3227 public:
3228
3229 ~option();
3230@@ -109,11 +107,11 @@
3231 /**
3232 * Construct an option instance.
3233 *
3234- * @param[in] creator Module that created this module.
3235+ * @param[in] module Module that created this option.
3236 * @param[in] name Name of option to create.
3237 */
3238 SCALESTACK_LOCAL
3239- option(module& creator, const std::string& name);
3240+ option(module& module, const std::string& name);
3241
3242 /**
3243 * Don't allow copying of objects.
3244@@ -171,6 +169,8 @@
3245 std::string _value_name;
3246 std::string _default_value;
3247 std::string _value;
3248+
3249+ friend class module;
3250 };
3251
3252 } /* namespace kernel */
3253
3254=== modified file 'scalestack/kernel/service.h'
3255--- scalestack/kernel/service.h 2010-06-03 04:51:37 +0000
3256+++ scalestack/kernel/service.h 2010-06-16 19:32:28 +0000
3257@@ -34,18 +34,18 @@
3258 {
3259 public:
3260
3261- service(module& creator);
3262+ service(kernel::module& module);
3263
3264 virtual ~service();
3265
3266 /**
3267 * Get the module associated with this service.
3268 */
3269- module& get_module(void);
3270+ kernel::module& get_module(void);
3271
3272 protected:
3273
3274- module& _module;
3275+ kernel::module& _module;
3276
3277 private:
3278
3279@@ -64,7 +64,7 @@
3280 * Public methods.
3281 */
3282
3283-inline service::service(module& creator):
3284+inline service::service(kernel::module& creator):
3285 _module(creator)
3286 {
3287 }
3288@@ -73,7 +73,7 @@
3289 {
3290 }
3291
3292-inline module& service::get_module(void)
3293+inline kernel::module& service::get_module(void)
3294 {
3295 return _module;
3296 }
3297
3298=== modified file 'scalestack/kernel/test/module.cc'
3299--- scalestack/kernel/test/module.cc 2010-06-03 04:51:37 +0000
3300+++ scalestack/kernel/test/module.cc 2010-06-16 19:32:28 +0000
3301@@ -57,7 +57,10 @@
3302
3303 TEST_BEGIN(get_option)
3304 kernel::module& module = core.get_or_add_module("module");
3305- kernel::option& option = module.add_option("option", "Help", "VALUE_NAME", "default_value");
3306+ kernel::option& option = module.add_option("option",
3307+ "Help",
3308+ "VALUE_NAME",
3309+ "default_value");
3310 assert(&module.get_option("option") == &option);
3311 TEST_EXCEPTION(module.get_option("Bad_option"));
3312 TEST_END
3313@@ -76,11 +79,17 @@
3314 assert(module.begin_option() == NULL);
3315 assert(module.next_option() == NULL);
3316
3317- kernel::option& option = module.add_option("option", "Help", "VALUE_NAME", "default_value");
3318+ kernel::option& option = module.add_option("option",
3319+ "Help",
3320+ "VALUE_NAME",
3321+ "default_value");
3322 assert(module.begin_option() == &option);
3323 assert(module.next_option() == NULL);
3324
3325- kernel::option& option2 = module.add_option("option2", "Help", "VALUE_NAME", "default_value");
3326+ kernel::option& option2 = module.add_option("option2",
3327+ "Help",
3328+ "VALUE_NAME",
3329+ "default_value");
3330 assert(module.begin_option() == &option);
3331 assert(module.next_option() == &option2);
3332 assert(module.next_option() == NULL);
3333
3334=== modified file 'scalestack/kernel/test/option.cc'
3335--- scalestack/kernel/test/option.cc 2010-06-03 04:51:37 +0000
3336+++ scalestack/kernel/test/option.cc 2010-06-16 19:32:28 +0000
3337@@ -48,7 +48,10 @@
3338
3339 TEST_BEGIN(constructor_value)
3340 kernel::module& module = core.get_or_add_module("module");
3341- kernel::option& option = module.add_option("option", "Help", "VALUE_NAME", "default_value");
3342+ kernel::option& option = module.add_option("option",
3343+ "Help",
3344+ "VALUE_NAME",
3345+ "default_value");
3346 assert(&option.get_module() == &module);
3347 assert(option.get_name() == "option");
3348 assert(option.get_help() == "Help");
3349
3350=== modified file 'scalestack/network/datagram.cc'
3351--- scalestack/network/datagram.cc 2010-06-03 04:51:37 +0000
3352+++ scalestack/network/datagram.cc 2010-06-16 19:32:28 +0000
3353@@ -35,8 +35,8 @@
3354 * Public methods.
3355 */
3356
3357-datagram_provider::datagram_provider(event::service& creator):
3358- event::handler(creator),
3359+datagram_provider::datagram_provider(event::handler_service& handler_service):
3360+ event::handler(handler_service),
3361 _file_descriptor(-1),
3362 _peer_size(),
3363 _receive_buffer_size(),
3364
3365=== modified file 'scalestack/network/datagram.h'
3366--- scalestack/network/datagram.h 2010-06-03 20:51:05 +0000
3367+++ scalestack/network/datagram.h 2010-06-16 19:32:28 +0000
3368@@ -47,7 +47,7 @@
3369
3370 public:
3371
3372- datagram(datagram_service& creator);
3373+ datagram(datagram_service& datagram_service);
3374
3375 virtual ~datagram();
3376
3377@@ -178,7 +178,7 @@
3378 {
3379 public:
3380
3381- datagram_provider(event::service& service);
3382+ datagram_provider(event::handler_service& handler_service);
3383
3384 virtual ~datagram_provider();
3385
3386@@ -333,9 +333,9 @@
3387 * Public datagram methods.
3388 */
3389
3390-inline datagram::datagram(datagram_service& creator):
3391- _module(creator.get_module()),
3392- _service(creator),
3393+inline datagram::datagram(datagram_service& datagram_service):
3394+ _module(datagram_service.get_module()),
3395+ _service(datagram_service),
3396 _datagram_provider(NULL)
3397 {
3398 }
3399
3400=== modified file 'scalestack/network/datagram_service.h'
3401--- scalestack/network/datagram_service.h 2010-06-03 04:51:37 +0000
3402+++ scalestack/network/datagram_service.h 2010-06-16 19:32:28 +0000
3403@@ -17,7 +17,7 @@
3404 #define SCALESTACK_NETWORK_DATAGRAM_SERVICE_H
3405
3406 #include <scalestack/common/macros.h>
3407-#include <scalestack/event/service.h>
3408+#include <scalestack/event/handler_service.h>
3409
3410 namespace scalestack
3411 {
3412@@ -26,11 +26,11 @@
3413
3414 class datagram;
3415
3416-class SCALESTACK_API datagram_service: public event::service
3417+class SCALESTACK_API datagram_service: public event::handler_service
3418 {
3419 public:
3420
3421- datagram_service(kernel::module& creator);
3422+ datagram_service(kernel::module& module);
3423
3424 virtual ~datagram_service();
3425
3426@@ -67,8 +67,8 @@
3427 * Public methods.
3428 */
3429
3430-inline datagram_service::datagram_service(kernel::module& creator):
3431- event::service(creator)
3432+inline datagram_service::datagram_service(kernel::module& module):
3433+ event::handler_service(module)
3434 {
3435 }
3436
3437
3438=== modified file 'scalestack/network/ip/tcp/listener_service.cc'
3439--- scalestack/network/ip/tcp/listener_service.cc 2010-06-03 04:51:37 +0000
3440+++ scalestack/network/ip/tcp/listener_service.cc 2010-06-16 19:32:28 +0000
3441@@ -56,9 +56,9 @@
3442 * Public methods.
3443 */
3444
3445-listener_service::listener_service(kernel::module& creator,
3446- connection_service& associated_connection_service):
3447- event::service(creator),
3448+listener_service::listener_service(kernel::module& module,
3449+ connection_service& connection_service):
3450+ event::handler_service(module),
3451 network::ip::common()
3452 {
3453 vector<pair<string,string> > hosts = _module.get_option("hosts").get_host_list_value();
3454@@ -76,11 +76,11 @@
3455 port != ports.end();
3456 ++port)
3457 {
3458- _add_listeners(associated_connection_service, host->first, *port);
3459+ _add_listeners(connection_service, host->first, *port);
3460 }
3461 }
3462 else
3463- _add_listeners(associated_connection_service, host->first, host->second);
3464+ _add_listeners(connection_service, host->first, host->second);
3465 }
3466 }
3467 catch (exception&)
3468@@ -99,7 +99,7 @@
3469 * Private methods.
3470 */
3471
3472-void listener_service::_add_listeners(connection_service& associated_connection_service,
3473+void listener_service::_add_listeners(connection_service& connection_service,
3474 std::string host,
3475 std::string port)
3476 {
3477@@ -130,7 +130,7 @@
3478 {
3479 try
3480 {
3481- new listener(*this, associated_connection_service, addrinfo);
3482+ new listener(*this, connection_service, addrinfo);
3483 added = true;
3484 }
3485 catch (exception&)
3486
3487=== modified file 'scalestack/network/ip/tcp/listener_service.h'
3488--- scalestack/network/ip/tcp/listener_service.h 2010-06-03 04:51:37 +0000
3489+++ scalestack/network/ip/tcp/listener_service.h 2010-06-16 19:32:28 +0000
3490@@ -18,7 +18,7 @@
3491
3492 #include <string>
3493
3494-#include <scalestack/event/service.h>
3495+#include <scalestack/event/handler_service.h>
3496 #include <scalestack/network/ip/common.h>
3497
3498 namespace scalestack
3499@@ -42,13 +42,13 @@
3500 SCALESTACK_API
3501 void listener_options(kernel::module& creator, const char* port);
3502
3503-class SCALESTACK_API listener_service: public event::service,
3504+class SCALESTACK_API listener_service: public event::handler_service,
3505 public network::ip::common
3506 {
3507 public:
3508
3509- listener_service(kernel::module& creator,
3510- connection_service& associated_connection_service);
3511+ listener_service(kernel::module& module,
3512+ connection_service& connection_service);
3513
3514 ~listener_service();
3515
3516
3517=== modified file 'scalestack/network/listener.cc'
3518--- scalestack/network/listener.cc 2010-06-03 04:51:37 +0000
3519+++ scalestack/network/listener.cc 2010-06-16 19:32:28 +0000
3520@@ -37,11 +37,11 @@
3521 * Public methods.
3522 */
3523
3524-listener::listener(event::service& creator,
3525- stream_service& associated_stream_service):
3526- event::handler(creator),
3527+listener::listener(event::handler_service& handler_service,
3528+ stream_service& stream_service):
3529+ event::handler(handler_service),
3530 _file_descriptor(-1),
3531- _stream_service(associated_stream_service)
3532+ _stream_service(stream_service)
3533 {
3534 _module.log_info(_("Listener constructed"));
3535 }
3536@@ -96,7 +96,7 @@
3537
3538 try
3539 {
3540- _service.add_handler(this);
3541+ _handler_service.add_handler(this);
3542 set_file_descriptor(_file_descriptor);
3543 watch_read();
3544 }
3545
3546=== modified file 'scalestack/network/listener.h'
3547--- scalestack/network/listener.h 2010-06-03 20:51:05 +0000
3548+++ scalestack/network/listener.h 2010-06-16 19:32:28 +0000
3549@@ -35,11 +35,12 @@
3550 /**
3551 * Constructor, setup associated services.
3552 *
3553- * @param[in] creator Service this listener is associated with.
3554- * @param[in] associated_stream_service Service this listener should add
3555- * streams to when it accepts new streams.
3556+ * @param[in] handler_service Service this listener is associated with.
3557+ * @param[in] stream_service Service this listener should add streams to
3558+ * when it accepts new streams.
3559 */
3560- listener(event::service& creator, stream_service& associated_stream_service);
3561+ listener(event::handler_service& handler_service,
3562+ stream_service& stream_service);
3563
3564 virtual ~listener();
3565
3566
3567=== modified file 'scalestack/network/local/stream/listener_service.cc'
3568--- scalestack/network/local/stream/listener_service.cc 2010-06-03 04:51:37 +0000
3569+++ scalestack/network/local/stream/listener_service.cc 2010-06-16 19:32:28 +0000
3570@@ -55,12 +55,12 @@
3571 * Public methods.
3572 */
3573
3574-listener_service::listener_service(kernel::module& creator,
3575- connection_service& associated_connection_service):
3576- event::service(creator),
3577+listener_service::listener_service(kernel::module& module,
3578+ connection_service& connection_service):
3579+ event::handler_service(module),
3580 network::local::common()
3581 {
3582- vector<string> local_sockets = creator.get_option("local_sockets").get_list_value();
3583+ vector<string> local_sockets = module.get_option("local_sockets").get_list_value();
3584
3585 try
3586 {
3587@@ -70,7 +70,7 @@
3588 {
3589 if (*local_socket != "")
3590 {
3591- _add_listener(associated_connection_service, *local_socket);
3592+ _add_listener(connection_service, *local_socket);
3593 }
3594 }
3595 }
3596
3597=== modified file 'scalestack/network/local/stream/listener_service.h'
3598--- scalestack/network/local/stream/listener_service.h 2010-06-03 04:51:37 +0000
3599+++ scalestack/network/local/stream/listener_service.h 2010-06-16 19:32:28 +0000
3600@@ -18,7 +18,7 @@
3601
3602 #include <string>
3603
3604-#include <scalestack/event/service.h>
3605+#include <scalestack/event/handler_service.h>
3606 #include <scalestack/network/local/common.h>
3607
3608 namespace scalestack
3609@@ -36,13 +36,13 @@
3610 /**
3611 * Add common options for Connection listen sockets.
3612 *
3613- * @param[in] creator Module that the service is associated with.
3614+ * @param[in] module Module that the service is associated with.
3615 * @param[in] port Default port to use.
3616 */
3617 SCALESTACK_API
3618-void listener_options(kernel::module& creator, const char* port);
3619+void listener_options(kernel::module& module, const char* port);
3620
3621-class SCALESTACK_API listener_service: public event::service,
3622+class SCALESTACK_API listener_service: public event::handler_service,
3623 public network::local::common
3624 {
3625 public:
3626
3627=== modified file 'scalestack/network/stream.cc'
3628--- scalestack/network/stream.cc 2010-06-03 04:51:37 +0000
3629+++ scalestack/network/stream.cc 2010-06-16 19:32:28 +0000
3630@@ -35,8 +35,8 @@
3631 * Public methods.
3632 */
3633
3634-stream_provider::stream_provider(event::service& creator):
3635- event::handler(creator),
3636+stream_provider::stream_provider(event::handler_service& handler_service):
3637+ event::handler(handler_service),
3638 _address_list(NULL),
3639 _current_address(NULL),
3640 _connecting(false),
3641
3642=== modified file 'scalestack/network/stream.h'
3643--- scalestack/network/stream.h 2010-06-03 04:51:37 +0000
3644+++ scalestack/network/stream.h 2010-06-16 19:32:28 +0000
3645@@ -47,7 +47,7 @@
3646
3647 public:
3648
3649- stream(stream_service& creator);
3650+ stream(stream_service& stream_service);
3651
3652 virtual ~stream();
3653
3654@@ -179,7 +179,7 @@
3655 {
3656 public:
3657
3658- stream_provider(event::service& creator);
3659+ stream_provider(event::handler_service& handler_service);
3660
3661 virtual ~stream_provider();
3662
3663@@ -358,9 +358,9 @@
3664 * Public stream methods.
3665 */
3666
3667-inline stream::stream(stream_service& creator):
3668- _module(creator.get_module()),
3669- _service(creator),
3670+inline stream::stream(stream_service& stream_service):
3671+ _module(stream_service.get_module()),
3672+ _service(stream_service),
3673 _stream_provider(NULL)
3674 {
3675 }
3676
3677=== modified file 'scalestack/network/stream_service.h'
3678--- scalestack/network/stream_service.h 2010-06-03 20:51:05 +0000
3679+++ scalestack/network/stream_service.h 2010-06-16 19:32:28 +0000
3680@@ -20,7 +20,7 @@
3681 #include <sys/types.h>
3682
3683 #include <scalestack/common/macros.h>
3684-#include <scalestack/event/service.h>
3685+#include <scalestack/event/handler_service.h>
3686
3687 namespace scalestack
3688 {
3689@@ -29,11 +29,11 @@
3690
3691 class stream;
3692
3693-class SCALESTACK_API stream_service: public event::service
3694+class SCALESTACK_API stream_service: public event::handler_service
3695 {
3696 public:
3697
3698- stream_service(kernel::module& creator);
3699+ stream_service(kernel::module& module);
3700
3701 virtual ~stream_service();
3702
3703@@ -82,8 +82,8 @@
3704 * Public methods.
3705 */
3706
3707-inline stream_service::stream_service(kernel::module& creator):
3708- event::service(creator)
3709+inline stream_service::stream_service(kernel::module& module):
3710+ event::handler_service(module)
3711 {
3712 }
3713

Subscribers

People subscribed via source and target branches

to all changes: