From 30c30438d5f6ce7cc9d458ff3a5a150687ca29fb Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 7 Jun 2007 03:33:49 +0000 Subject: [PATCH] has_thread() etc. --- panda/src/gobj/vertexDataPage.I | 15 +++++++++++++++ panda/src/gobj/vertexDataPage.cxx | 4 ++++ panda/src/gobj/vertexDataPage.h | 2 ++ 3 files changed, 21 insertions(+) diff --git a/panda/src/gobj/vertexDataPage.I b/panda/src/gobj/vertexDataPage.I index abc0728253..c5f373fbba 100644 --- a/panda/src/gobj/vertexDataPage.I +++ b/panda/src/gobj/vertexDataPage.I @@ -135,6 +135,21 @@ save_to_disk() { return do_save_to_disk(); } +//////////////////////////////////////////////////////////////////// +// Function: VertexDataPage::has_thread +// Access: Published, Static +// Description: Returns true if a thread has been spawned to service +// vertex paging requests, or false if it has not (which +// may mean either that all paging requests will be +// handled by the main thread, or simply that no paging +// requests have yet been issued). +//////////////////////////////////////////////////////////////////// +INLINE bool VertexDataPage:: +has_thread() { + MutexHolder holder(_tlock); + return !_thread.is_null(); +} + //////////////////////////////////////////////////////////////////// // Function: VertexDataPage::get_page_data // Access: Public diff --git a/panda/src/gobj/vertexDataPage.cxx b/panda/src/gobj/vertexDataPage.cxx index 3176c88258..b944bcdd75 100644 --- a/panda/src/gobj/vertexDataPage.cxx +++ b/panda/src/gobj/vertexDataPage.cxx @@ -165,6 +165,8 @@ stop_thread() { } if (thread != (PageThread *)NULL) { + gobj_cat.info() + << "Stopping vertex paging thread.\n"; thread->stop_thread(); } } @@ -512,6 +514,8 @@ request_ram_class(RamClass ram_class) { MutexHolder holder(_tlock); if (_thread == (PageThread *)NULL) { // Allocate and start a new global thread. + gobj_cat.info() + << "Spawning vertex paging thread.\n"; _thread = new PageThread; _thread->start(TP_low, true); } diff --git a/panda/src/gobj/vertexDataPage.h b/panda/src/gobj/vertexDataPage.h index 3cb03d2421..e38b6d715d 100644 --- a/panda/src/gobj/vertexDataPage.h +++ b/panda/src/gobj/vertexDataPage.h @@ -71,6 +71,8 @@ PUBLISHED: INLINE static VertexDataSaveFile *get_save_file(); INLINE bool save_to_disk(); + + INLINE static bool has_thread(); static void stop_thread(); public: