message_queue.hpp

来自「ncbi源码」· HPP 代码 · 共 168 行

HPP
168
字号
/* * =========================================================================== * PRODUCTION $Log: message_queue.hpp,v $ * PRODUCTION Revision 1000.4  2004/04/12 18:12:33  gouriano * PRODUCTION PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.11 * PRODUCTION * =========================================================================== */#ifndef GUI_GBENCH___MESSAGE_QUEUE__HPP#define GUI_GBENCH___MESSAGE_QUEUE__HPP/*  $Id: message_queue.hpp,v 1000.4 2004/04/12 18:12:33 gouriano Exp $ * =========================================================================== * *                            PUBLIC DOMAIN NOTICE *               National Center for Biotechnology Information * *  This software/database is a "United States Government Work" under the *  terms of the United States Copyright Act.  It was written as part of *  the author's official duties as a United States Government employee and *  thus cannot be copyrighted.  This software/database is freely available *  to the public for use. The National Library of Medicine and the U.S. *  Government have not placed any restriction on its use or reproduction. * *  Although all reasonable efforts have been taken to ensure the accuracy *  and reliability of the software and data, the NLM and the U.S. *  Government do not and cannot warrant the performance or results that *  may be obtained by using this software or data. The NLM and the U.S. *  Government disclaim all warranties, express or implied, including *  warranties of performance, merchantability or fitness for any particular *  purpose. * *  Please cite the author in any work or product based on this material. * * =========================================================================== * * Authors:  Mati Shomrat * * File Description: *    CMessageQueue - GBench message queue */#include <corelib/ncbistd.hpp>#include <util/thread_pool.hpp>#include <gui/plugin/PluginMessage.hpp>BEGIN_NCBI_SCOPEclass CPluginTask;/* * CPluginMessageQueue provides the public (static) interface for * the GenomeWorkbench message queue. */class NCBI_XGBPLUGIN_EXPORT CPluginMessageQueue{public:    //~CPluginMessageQueue();    // Process a single message off of the queue.    // Blocks for no longer that the specified timeout.    static void ProcessMessage(size_t timeout_sec  = kMax_UInt,                               size_t timeout_nsec = kMax_UInt) THROWS_NONE;    // process an indicated message.  This will perform the tasks immediately,    // and do all history logging    static void ProcessMessage(objects::CPluginMessage& msg);    // Add a message to the queue.    // returns 'true' if successfully added, 'false' otherwise.    static bool Add(objects::CPluginMessage& msg) THROWS_NONE;    // Get a message.     // Blocks for no longer that the specified timeout.    // Will return an empty CConstRef if no message was retrieved.    static objects::CPluginMessage*    Get(size_t timeout_sec  = kMax_UInt,        size_t timeout_nsec = kMax_UInt) THROWS_NONE;        // The number of messages currently in the queue.    static SIZE_TYPE Size(void) THROWS_NONE;    // Storage allocated for the queue    static SIZE_TYPE Capacity(void) THROWS_NONE;    // query whether the queue is full or empty    static bool IsFull(void) THROWS_NONE;    static bool IsEmpty(void) THROWS_NONE;    // clear the message queue    static void Clear(void) THROWS_NONE;private:    // types    typedef CRef<objects::CPluginMessage> TMessage;    typedef CBlockingQueue<TMessage>      TMessageQueue;    typedef list<CRef<CPluginTask> >      TTasks;    // the one and only message queue    static TMessageQueue sm_Queue;    // a parallel task queue to hold messages in progress    static TTasks sm_TaskList;    // drop a message    static void x_DropMessage(const objects::CPluginMessage& msg);};END_NCBI_SCOPE#endif  // GUI_GBENCH___MESSAGE_QUEUE__HPP/* * =========================================================================== * $Log: message_queue.hpp,v $ * Revision 1000.4  2004/04/12 18:12:33  gouriano * PRODUCTION: UPGRADED [CATCHUP_003] Dev-tree R1.11 * * Revision 1.11  2004/04/07 12:33:58  dicuccio * Dropped x_ProcessReply() - not used anymore * * Revision 1.10  2003/12/31 20:31:24  dicuccio * Deleted dead code * * Revision 1.9  2003/12/22 19:12:40  dicuccio * Removed internal singleton - cleans up the calling API significantly * * Revision 1.8  2003/11/18 17:35:53  dicuccio * Removed unnecessary static const member variable.  Added API to separate reply * processing from message handling * * Revision 1.7  2003/11/14 17:43:05  dicuccio * Added Clear() * * Revision 1.6  2003/11/04 17:11:15  dicuccio * Merged dispatcher/message queue.  Added function to force processing of a * single message out of the queue * * Revision 1.5  2003/08/22 15:54:48  dicuccio * General clean-up:  Removed unneeded export specifiers from templates; removed * 'USING_SCOPE(objects)' * * Revision 1.4  2003/08/05 16:58:39  dicuccio * Changed calling conventions for plugin message queue - pass by reference, not * CConstRef<> * * Revision 1.3  2003/07/31 16:41:49  dicuccio * Changed class name to be application-agnostic.  Moved instance creation into * .cpp file.  Changed mutex to use correct static initialization * * Revision 1.2  2003/07/15 15:10:28  ucko * Make the guard for sm_Instance a static class member, since Darwin's * shared-library linker doesn't like inline functions with static locals. * * Revision 1.1  2003/07/14 10:52:14  shomrat * Initial Revision *  * =========================================================================== */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?