You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2011/06/05 10:57:01 UTC
svn commit: r1132193 - in /incubator/mesos/trunk/third_party/libprocess:
process.cpp process.hpp
Author: benh
Date: Sun Jun 5 08:57:01 2011
New Revision: 1132193
URL: http://svn.apache.org/viewvc?rev=1132193&view=rev
Log:
Updated 'serve' to take both a timeout and a flag.
Modified:
incubator/mesos/trunk/third_party/libprocess/process.cpp
incubator/mesos/trunk/third_party/libprocess/process.hpp
Modified: incubator/mesos/trunk/third_party/libprocess/process.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/process.cpp?rev=1132193&r1=1132192&r2=1132193&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/process.cpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/process.cpp Sun Jun 5 08:57:01 2011
@@ -2712,29 +2712,30 @@ MSGID Process::receive(double secs)
}
-MSGID Process::serve(double secs)
+MSGID Process::serve(double secs, bool forever)
{
- switch (receive(secs)) {
- case PROCESS_DISPATCH: {
- void *pointer = (char *) current + sizeof(struct msg);
- std::tr1::function<void (void)> *delegator =
- *reinterpret_cast<std::tr1::function<void (void)> **>(pointer);
- (*delegator)();
- delete delegator;
- break;
- }
+ do {
+ switch (receive(secs)) {
+ case PROCESS_DISPATCH: {
+ void *pointer = (char *) current + sizeof(struct msg);
+ std::tr1::function<void (void)> *delegator =
+ *reinterpret_cast<std::tr1::function<void (void)> **>(pointer);
+ (*delegator)();
+ delete delegator;
+ break;
+ }
- default: {
- return msgid();
+ default: {
+ return msgid();
+ }
}
- }
+ } while (forever);
}
void Process::operator () ()
{
- while (true)
- serve();
+ serve();
}
Modified: incubator/mesos/trunk/third_party/libprocess/process.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/process.hpp?rev=1132193&r1=1132192&r2=1132193&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/process.hpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/process.hpp Sun Jun 5 08:57:01 2011
@@ -160,7 +160,7 @@ protected:
virtual MSGID receive(double secs = 0);
/* Processes dispatch messages. */
- virtual MSGID serve(double secs = 0);
+ virtual MSGID serve(double secs = 0, bool forever = true);
/* Blocks at least specified seconds (may block longer). */
virtual void pause(double secs);