00001 /** @file 00002 00003 Public declaration of Processor class 00004 00005 @section license License 00006 00007 Licensed to the Apache Software Foundation (ASF) under one 00008 or more contributor license agreements. See the NOTICE file 00009 distributed with this work for additional information 00010 regarding copyright ownership. The ASF licenses this file 00011 to you under the Apache License, Version 2.0 (the 00012 "License"); you may not use this file except in compliance 00013 with the License. You may obtain a copy of the License at 00014 00015 http://www.apache.org/licenses/LICENSE-2.0 00016 00017 Unless required by applicable law or agreed to in writing, software 00018 distributed under the License is distributed on an "AS IS" BASIS, 00019 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00020 See the License for the specific language governing permissions and 00021 limitations under the License. 00022 00023 */ 00024 00025 #ifndef _I_Processor_h_ 00026 #define _I_Processor_h_ 00027 00028 #include "libts.h" 00029 00030 #define PROCESSOR_RECONFIGURE 0x01 00031 #define PROCESSOR_CHECK 0x02 00032 #define PROCESSOR_FIX 0x04 00033 #define PROCESSOR_IGNORE_ERRORS 0x08 00034 00035 class Processor; 00036 class Thread; 00037 00038 /** 00039 Base class for all of the IO Core processors. 00040 00041 The Processor class defines a common interface for all the 00042 processors in the IO Core. A processor is multithreaded subsystem 00043 specialized in some type of task or application. For example, 00044 the Event System module includes the EventProcessor which provides 00045 schedulling services, the Net module includes the NetProcessor 00046 which provides networking services, etc. 00047 00048 You cannot create objects of the Processor class and its methods 00049 have no implementation. Therefore, you are expected to use objects 00050 of a derived type. 00051 00052 Most of such derived classes, provide a singleton object and is 00053 common case to have a single instance in that application scope. 00054 00055 */ 00056 class Processor 00057 { 00058 public: 00059 virtual ~Processor(); 00060 00061 /** 00062 Returns a Thread appropriate for the processor. 00063 00064 Returns a new instance of a Thread or Thread derived class of 00065 a thread which is the thread class for the processor. 00066 00067 @param thread_index reserved for future use. 00068 00069 */ 00070 virtual Thread *create_thread(int thread_index); 00071 00072 /** 00073 Returns the number of threads required for this processor. If 00074 the number is not defined or not used, it is equal to 0. 00075 00076 */ 00077 virtual int get_thread_count(); 00078 00079 /** 00080 This function attemps to stop the processor. Please refer to 00081 the documentation on each processor to determine if it is 00082 supported. 00083 00084 */ 00085 virtual void shutdown() 00086 { 00087 } 00088 00089 /** 00090 Starts execution of the processor. 00091 00092 Attempts to start the number of threads specified for the 00093 processor, initializes their states and sets them running. On 00094 failure it returns a negative value. 00095 00096 @param number_of_threads Positive value indicating the number of 00097 threads to spawn for the processor. 00098 @param stacksize The thread stack size to use for this processor. 00099 00100 */ 00101 virtual int start(int number_of_threads, size_t stacksize=DEFAULT_STACKSIZE) 00102 { 00103 (void) number_of_threads; 00104 (void) stacksize; 00105 return 0; 00106 } 00107 00108 protected: 00109 Processor(); 00110 00111 private: 00112 // prevent unauthorized copies (Not implemented) 00113 Processor(const Processor &); 00114 Processor & operator =(const Processor &); 00115 }; 00116 00117 #endif //_I_Processor_h_