summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXant <xant@dyne.org>2009-07-25 18:57:51 (GMT)
committer Xant <xant@dyne.org>2009-07-25 18:57:51 (GMT)
commitd221ae353737fd0f4bb1452dfd7fc1345a042130 (patch)
tree2a79181ae5a5bb869c2f6434aabc7889fd20e590
parent5b911656ddc3cec0750dcb46db13746d5d0d3ef7 (diff)
parente20baeb9de647cf44c8b5f23ba64566326d45804 (diff)
Merge branch 'trunk' of ssh://git@code.dyne.org/freej into trunkDP_presentation
-rw-r--r--src/callback.cpp2
-rw-r--r--src/closure.cpp26
-rw-r--r--src/include/callback.h10
-rw-r--r--src/include/closure.h18
-rw-r--r--src/include/layer.h2
-rw-r--r--src/layer.cpp2
6 files changed, 30 insertions, 30 deletions
diff --git a/src/callback.cpp b/src/callback.cpp
index e200fc0..36af0f6 100644
--- a/src/callback.cpp
+++ b/src/callback.cpp
@@ -59,7 +59,7 @@ void DumbCall::dequeue() {
}
DumbCallback::DumbCallback() {
- dispatcher_ = new ThreadedClosing();
+ dispatcher_ = new ThreadedClosureQueue();
}
DumbCallback::~DumbCallback() {
diff --git a/src/closure.cpp b/src/closure.cpp
index 501d734..34e799c 100644
--- a/src/closure.cpp
+++ b/src/closure.cpp
@@ -19,13 +19,13 @@
#include <jutils.h>
-Closing::Closing() {
+ClosureQueue::ClosureQueue() {
int r;
if ((r=pthread_mutex_init(&job_queue_mutex_, NULL)) != 0)
throw Error("Initializing job_queue_mutex_", r);
}
-Closing::~Closing() {
+ClosureQueue::~ClosureQueue() {
int r;
do_jobs(); // flush queue
if ((r=pthread_mutex_destroy(&job_queue_mutex_)) != 0)
@@ -33,7 +33,7 @@ Closing::~Closing() {
__PRETTY_FUNCTION__, strerror(r));
}
-void Closing::add_job(Closure *job) {
+void ClosureQueue::add_job(Closure *job) {
int r;
if ((r=pthread_mutex_lock(&job_queue_mutex_)) != 0)
throw Error("Locking job_queue_mutex_ to add job", r);
@@ -42,7 +42,7 @@ void Closing::add_job(Closure *job) {
throw Error("Unlocking job_queue_mutex_ to add job", r);
}
-Closure *Closing::get_job_() {
+Closure *ClosureQueue::get_job_() {
Closure *job = NULL;
int r;
if ((r=pthread_mutex_lock(&job_queue_mutex_)) != 0)
@@ -56,7 +56,7 @@ Closure *Closing::get_job_() {
return job;
}
-void Closing::do_jobs() {
+void ClosureQueue::do_jobs() {
Closure *job;
bool to_delete;
// TODO(shammash): maybe we'll need a timed condition to exit the loop
@@ -70,7 +70,7 @@ void Closing::do_jobs() {
-ThreadedClosing::ThreadedClosing() {
+ThreadedClosureQueue::ThreadedClosureQueue() {
int r;
running_ = true;
if ((r=pthread_mutex_init(&cond_mutex_, NULL)) != 0)
@@ -81,11 +81,11 @@ ThreadedClosing::ThreadedClosing() {
throw Error("Initializing attr_", r);
if ((r=pthread_attr_setdetachstate(&attr_, PTHREAD_CREATE_JOINABLE)) != 0)
throw Error("Setting attr_ joinable", r);
- if ((r=pthread_create(&thread_, &attr_, &ThreadedClosing::jobs_loop_, this)) != 0)
+ if ((r=pthread_create(&thread_, &attr_, &ThreadedClosureQueue::jobs_loop_, this)) != 0)
throw Error("Creating jobs_loop_ thread", r);
}
-ThreadedClosing::~ThreadedClosing() {
+ThreadedClosureQueue::~ThreadedClosureQueue() {
int r;
running_ = false;
signal_();
@@ -103,7 +103,7 @@ ThreadedClosing::~ThreadedClosing() {
__PRETTY_FUNCTION__, strerror(r));
}
-void ThreadedClosing::signal_() {
+void ThreadedClosureQueue::signal_() {
int r;
if ((r=pthread_mutex_lock(&cond_mutex_)) != 0)
throw Error("Pre-signal locking of cond_mutex_", r);
@@ -113,14 +113,14 @@ void ThreadedClosing::signal_() {
throw Error("Post-signal unlocking of cond_mutex_", r);
}
-void ThreadedClosing::add_job(Closure *job) {
- Closing::add_job(job);
+void ThreadedClosureQueue::add_job(Closure *job) {
+ ClosureQueue::add_job(job);
signal_();
}
-void *ThreadedClosing::jobs_loop_(void *arg) {
+void *ThreadedClosureQueue::jobs_loop_(void *arg) {
int r;
- ThreadedClosing *me = (ThreadedClosing *)arg;
+ ThreadedClosureQueue *me = (ThreadedClosureQueue *)arg;
if ((r=pthread_mutex_lock(&me->cond_mutex_)) != 0)
throw ThreadError("First lock of cond_mutex_", r);
while (me->running_) {
diff --git a/src/include/callback.h b/src/include/callback.h
index f4940a4..d5280cb 100644
--- a/src/include/callback.h
+++ b/src/include/callback.h
@@ -98,7 +98,7 @@ namespace callbacks {
return true;
}
- void notify(ThreadedClosing *dispatcher) {
+ void notify(ThreadedClosureQueue *dispatcher) {
std::list<FunctionType>::iterator i;
for (i=calls_.begin() ; i!=calls_.end() ; i++)
dispatcher->add_job(NewClosure(*i));
@@ -152,7 +152,7 @@ namespace callbacks {
return true;
}
- void notify(ThreadedClosing *dispatcher, Arg1 arg1) {
+ void notify(ThreadedClosureQueue *dispatcher, Arg1 arg1) {
typename std::list<FunctionType>::iterator i;
for (i=calls_.begin() ; i!=calls_.end() ; i++)
dispatcher->add_job(NewClosure(*i, arg1));
@@ -176,7 +176,7 @@ namespace callbacks {
class CallbackHandler {
public:
- CallbackHandler() { dispatcher_ = new ThreadedClosing(); }
+ CallbackHandler() { dispatcher_ = new ThreadedClosureQueue(); }
~CallbackHandler() {
cbacks_.clear();
delete dispatcher_;
@@ -293,7 +293,7 @@ class CallbackHandler {
}
std::list<callbacks::CbackData*> cbacks_;
- ThreadedClosing *dispatcher_;
+ ThreadedClosureQueue *dispatcher_;
};
#endif
@@ -331,7 +331,7 @@ class DumbCallback {
DumbCall *get_call_(DumbCall *call);
std::list<DumbCall *> calls_;
- ThreadedClosing *dispatcher_;
+ ThreadedClosureQueue *dispatcher_;
};
diff --git a/src/include/closure.h b/src/include/closure.h
index fab86b0..4081293 100644
--- a/src/include/closure.h
+++ b/src/include/closure.h
@@ -29,17 +29,17 @@
class Closure;
/*
- * Closing and ThreadedClosing classes provide a thread-safe queue of Closures.
+ * ClosureQueue and ThreadedClosureQueue classes provide a thread-safe queue of Closures.
*
- * Closing lets you insert a Closure in the queue and then run all the Closures
+ * ClosureQueue lets you insert a Closure in the queue and then run all the Closures
* by hand.
*
- * ThreadedClosing lets you insert a Closure in the queue; the execution of
+ * ThreadedClosureQueue lets you insert a Closure in the queue; the execution of
* enqueued Closures is handled automatically by an internal thread.
*
*/
-class Closing {
+class ClosureQueue {
public:
class Error : public FreejError {
public:
@@ -47,8 +47,8 @@ class Closing {
: FreejError(msg, rv) { }
};
- Closing();
- ~Closing();
+ ClosureQueue();
+ ~ClosureQueue();
void add_job(Closure *job);
void do_jobs();
@@ -60,7 +60,7 @@ class Closing {
};
-class ThreadedClosing : Closing {
+class ThreadedClosureQueue : ClosureQueue {
public:
class Error : public FreejError {
public:
@@ -74,8 +74,8 @@ class ThreadedClosing : Closing {
: Error(msg, rv) { }
};
- ThreadedClosing();
- ~ThreadedClosing();
+ ThreadedClosureQueue();
+ ~ThreadedClosureQueue();
void add_job(Closure *job);
diff --git a/src/include/layer.h b/src/include/layer.h
index a0e4841..ab1a232 100644
--- a/src/include/layer.h
+++ b/src/include/layer.h
@@ -230,7 +230,7 @@ class Layer: public Entry, public JSyncThread {
protected:
- Closing *deferred_calls;
+ ClosureQueue *deferred_calls;
void _init(int wdt, int hgt);
///< Layer abstract initialization
diff --git a/src/layer.cpp b/src/layer.cpp
index c37c8ea..f69aba9 100644
--- a/src/layer.cpp
+++ b/src/layer.cpp
@@ -40,7 +40,7 @@
Layer::Layer()
:Entry(), JSyncThread() {
func("%s this=%p",__PRETTY_FUNCTION__, this);
- deferred_calls = new Closing();
+ deferred_calls = new ClosureQueue();
env = NULL;
quit = false;
active = false;