[libvirt] [PATCH RFC 06/12] Add API for thread cancellation

Daniel P. Berrange berrange at redhat.com
Mon Jan 23 17:34:14 UTC 2012


From: "Daniel P. Berrange" <berrange at redhat.com>

* src/util/threads-pthread.c, src/util/threads.h: Add virThreadCancel
---
 src/util/threads-pthread.c |    5 +++++
 src/util/threads.h         |    1 +
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/util/threads-pthread.c b/src/util/threads-pthread.c
index 5b8fd5b..34eceb6 100644
--- a/src/util/threads-pthread.c
+++ b/src/util/threads-pthread.c
@@ -233,6 +233,11 @@ void virThreadJoin(virThreadPtr thread)
     pthread_join(thread->thread, NULL);
 }
 
+void virThreadCancel(virThreadPtr thread)
+{
+    pthread_cancel(thread->thread);
+}
+
 int virThreadLocalInit(virThreadLocalPtr l,
                        virThreadLocalCleanup c)
 {
diff --git a/src/util/threads.h b/src/util/threads.h
index e52f3a9..329288e 100644
--- a/src/util/threads.h
+++ b/src/util/threads.h
@@ -53,6 +53,7 @@ int virThreadCreate(virThreadPtr thread,
 void virThreadSelf(virThreadPtr thread);
 bool virThreadIsSelf(virThreadPtr thread);
 void virThreadJoin(virThreadPtr thread);
+void virThreadCancel(virThreadPtr thread);
 
 /* These next two functions are for debugging only, since they are not
  * guaranteed to give unique values for distinct threads on all
-- 
1.7.7.5




More information about the libvir-list mailing list