当前位置:首页>Linux>Linux多线程编程(三):手写环形队列、日志系统与线程池

Linux多线程编程(三):手写环形队列、日志系统与线程池

  • 2026-07-02 16:31:11
Linux多线程编程(三):手写环形队列、日志系统与线程池

文章目录

  • 1、POSIX信号量
    • 1.1、信号量简介
    • 1.2、信号量常用接口
  • 2、基于环形队列的生产者消费者模型
    • 2.1、实现原理
    • 2.2、具体实现
  • 3、日志与策略模式
    • 3.1、策略模式
    • 3.2、日志类实现
  • 4、单例模式线程池
    • 4.1、线程池实现
    • 4.2、引入单例模式
  • 5、总结

1、POSIX信号量

POSIX信号量分为有名信号量、无名信号量。这里介绍无名信号量。

1.1、信号量简介

信号量用于进程/线程间同步/互斥机制。信号量本质是一个计数器,通过P(Proberen)操作减一、V(Verhogen)操作加一。

信号量是对资源的预定机制,资源预定后,其他执行流不能再访问。因此,信号量可以实现互斥锁。互斥锁就是一个二元信号量。

P操作:对计数器做原子性减一。如果计数器大于0,申请资源成功。如果计数器小于等于0,线程阻塞或失败返回。

V操作:对计数器做原子性加一。唤醒阻塞中的线程(如果有)。

1.2、信号量常用接口

初始化信号量:

intsem_init(sem_t *sem, int pshared, unsignedint value);

参数:

  • sem:需要初始化的信号量。
  • pshared:为0时,在线程间共享。非0时,传递sem的共享内存区域,在进程间共享。
  • value:初始化计数器的值。

销毁信号量

intsem_destroy(sem_t *sem);

P操作:

intsem_wait(sem_t *sem);

计数器减一。除此之外P操作还有尝试等待int sem_trywait(sem_t *sem);、超时等待int sem_timedwait(sem_t *restrict sem, const struct timespec *restrict abs_timeout);

V操作:

intsem_post(sem_t *sem);

计数器加一。


对信号量的封装:

#ifndef __SEM__HPP#define __SEM__HPP#include<semaphore.h>namespace NS_SEM_MODULE{    class Sem    {    public:        Sem(int val)        {            sem_init(&_sem, 0, val);        }        voidP()        {            sem_wait(&_sem);        }        voidV()        {            sem_post(&_sem);        }        ~Sem()        {            sem_destroy(&_sem);        }    private:        sem_t _sem;    };}#endif

2、基于环形队列的生产者消费者模型

2.1、实现原理

上一文中写的是基于阻塞队列的生产者消费模型,通过互斥锁与条件变量实现。互斥锁保护的是整个队列,而基于环形队列的模型则是保护队列中具体元素。

C++中的stl容器进程增删查改都不是线程安全的。所以我们要自己写一个环形队列。队列中每一个元素都是线程安全的。

通过信号量保证不会有太多的线程访问队列,通过算法的设计保证不同的线程访问到的是队列中的不同元素。

一个环形队列中有两种资源:数据资源、空格资源。消费者关心数据资源,当数据资源没了就不能再用了。生产者关心空格资源,当空格资源没了就不能再生产了。

把空格和和数据同时看作资源,信号量的操作就是对资源的预定机制。

实现队列使用数组模拟,_consumer_step_producer_step指向队头和队尾,通过取模实现环形效果。

队列必须遵守4个原则:

  1. 没有数据资源时,消费者必须等待。
  2. 没有空格资源时,生产者必须等待。
  3. 消费者不能超过生产者。
  4. 生产者不能套圈消费者。

2.2、具体实现

本节代码已上传置gitee【https://gitee.com/muyi-2580/learning-linux/tree/main/5_30】。 RangQueue.hpp:

#include<vector>#include"Sem.hpp"#include"Mutex.hpp"template<class T>class RangQueue{public:    RangQueue(int cap)        :_cap(cap)        ,_consumer_step(0)        ,_producer_step(0)        ,_blank_sem(_cap)        ,_data_sem(0)    {         _rang_que.resize(_cap);    }    ~RangQueue()    {  }    voidEnqueue(const T& in)// 生产者调用,数据入队    {        // 预定空格资源减少,P操作        _blank_sem.P();        {            NS_MUTEX_MUDULE::LockGuard g_mutex(_d_mutex);            _rang_que[_producer_step++] = in;            _producer_step %= _cap;        }        // 数据资源增加,V操作        _data_sem.V();    }    voidPop(T* out)// 消费者调用,数据出队    {        // 预定数据资源减少,P操作        _data_sem.P();        {            NS_MUTEX_MUDULE::LockGuard g_mutex(_b_mutex);            *out = _rang_que[_consumer_step++];            _consumer_step %= _cap;        }        // 空格资源增加,V操作        _blank_sem.V();    }private:    int _cap;                       // 大小    int _consumer_step;             // 消费者位置    int _producer_step;             // 生产者位置    NS_SEM_MODULE::Sem _blank_sem;  // 空格资源    NS_SEM_MODULE::Sem _data_sem;   // 数据资源    NS_MUTEX_MUDULE::Mutex _d_mutex;// 生产者锁    NS_MUTEX_MUDULE::Mutex _b_mutex;// 消费者锁    std::vector<T> _rang_que;       // 环形队列};

Main.cc

#include"Mutex.hpp"#include"RangQueue.hpp"#include"Thread.hpp"#include<iostream>#include<memory.h>#include<memory>#include<unistd.h>int num = 1;std::unique_ptr<RangQueue<int>> rq(new RangQueue<int>(10));NS_MUTEX_MUDULE::Mutex mutex;intGetNum(){    static NS_MUTEX_MUDULE::Mutex mutex;    NS_MUTEX_MUDULE::LockGuard lg(mutex);    return num++;}voidProducerRoutine(){    while(1)    {        int val = GetNum();        rq->Enqueue(val);        {            NS_MUTEX_MUDULE::LockGuard lg(mutex);            std::cout << "produce: " << val << std::endl;        }        // 生产得慢        usleep(100000);    }    pthread_exit(nullptr);}voidConsumerRoutine(){    while(1)    {        int data = 0;        rq->Pop(&data);        {            NS_MUTEX_MUDULE::LockGuard lg(mutex);            std::cout << "ConsumerRoutine: " << data << std::endl;        }        // 消费得快        usleep(1000);    }    pthread_exit(nullptr);}intmain(){    NS_THREAD_MUDULE::Thread c1(ConsumerRoutine);    NS_THREAD_MUDULE::Thread c2(ConsumerRoutine);    NS_THREAD_MUDULE::Thread c3(ConsumerRoutine);    NS_THREAD_MUDULE::Thread p1(ProducerRoutine);    NS_THREAD_MUDULE::Thread p2(ProducerRoutine);    NS_THREAD_MUDULE::Thread p3(ProducerRoutine);    c1.start();    c2.start();    c3.start();    p1.start();    p2.start();    p3.start();    c1.join();    c2.join();    c3.join();    p1.join();    p2.join();    p3.join();    return 0;}

结果 注意图中的ConsumerRoutine: 2produce: 2之前是完全正常的。因为这只能代表输出顺序,偶尔一两个是正常的,大面积出现时可能出问题。

3、日志与策略模式

3.1、策略模式

设计模式是一些经验丰富的大佬总结出来的一些方式,采用这些方式能使代码耦合度更低,更利于维护。常用的模式有23种,本大节使用策略模式设计一个日志。

策略模式原理是多态,基类指针或者引用指向派生类。

实现如下:

enum class LogLevel{    INFO,    WARNING,    ERRNO,    FATAL,    DEBUG};class LogStrategy{public:    LogStrategy(){  }     virtualvoidSyncLog(const std::string message)0;private:    NS_MUTEX_MUDULE::Mutex mutex;};class ConsoleStrategy : public LogStrategy{public:    ConsoleStrategy() { }    voidSyncLog(const std::string message)    {        NS_MUTEX_MUDULE::LockGuard lockguard(mutex);        std::cerr << message << '\n';    }private:    NS_MUTEX_MUDULE::Mutex mutex;};class FileStrategy : public LogStrategy{public:    FileStrategy(std::string path = "./log/", std::string filename = "log.txt")        :_path(path)        ,_filename(filename)    {        if(!_path.empty() && _path.back() != '/')        {            _path += '/';        }        try        {            std::filesystem::create_directories(_path);        }        catch(const std::filesystem::filesystem_error& e)        {            std::cerr << e.what() << '\n';        }    }    voidSyncLog(const std::string message)override    {        NS_MUTEX_MUDULE::LockGuard lockguard(mutex);        std::ofstream out(_path + _filename, std::ios::app);        if(!out.is_open())        {            std::cerr << "ofstream " << _path << _filename << '\n';        }        out << message << '\n';        out.close();    }private:    std::string _path;    std::string _filename;    NS_MUTEX_MUDULE::Mutex mutex;};

3.2、日志类实现

日志格式如图: 代码的类关系图如下:

#ifndef __LOGGER_HPP#define __LOGGER_HPP#include"Mutex.hpp"#include<ctime>#include<sys/time.h>#include<unistd.h>#include<string>#include<memory>#include<sstream>#include<fstream>#include<iostream>#include<filesystem>#include<unordered_map>namespace NS_LOGGER_MUDULE{    const std::unordered_map<LogLevel, std::string> map = {        {LogLevel::INFO, "INFO"},        {LogLevel::WARNING, "WARNING"},        {LogLevel::ERRNO, "ERRNO"},        {LogLevel::FATAL, "FATAL"},        {LogLevel::DEBUG, "DEBUG"}    };    std::string GetCurTime()    {        time_t t_t = time(0);        tm t_m;        localtime_r(&t_t, &t_m);        char retstr[128];        snprintf(retstr, sizeof(retstr), "%04d-%02d-%02d:%02d:%02d:%02d",                t_m.tm_year,                t_m.tm_mon,                t_m.tm_mday,                t_m.tm_hour,                t_m.tm_min,                t_m.tm_sec                );        return std::string(retstr);    }    class Logger    {    private:        class LogMessage        {        public:            LogMessage(LogLevel level, std::string& file, int line, Logger& logger)                :_curtime(GetCurTime())                ,_level(level)                ,_pid(getpid())                ,_file(file)                ,_line(line)                ,_logger(logger)            {                std::stringstream ss;                ss << "[" << _curtime << "] " <<                    "[" << map.at(_level) << "] " <<                    "[" << _pid << "] " <<                    "[" << file << "] " <<                    "[" << line << "] ";                _loginfo = ss.str();            }            template<class T>            LogMessage& operator<<(const T& info)            {                std::stringstream ss;                 ss << info;                _loginfo += ss.str();                return *this;            }            ~LogMessage()            {                _logger._strategy->SyncLog(_loginfo);            }        private:            std::string _curtime;            LogLevel _level;            pid_t _pid;            std::string _file;            int _line;            Logger& _logger;            std::string _loginfo;        };    public:        Logger()        {            UseConsoleStrategy();        }        voidUseConsoleStrategy()        {            _strategy = std::make_unique<ConsoleStrategy>();        }        voidUseFileStrategy()        {            _strategy = std::make_unique<FileStrategy>();        }        LogMessage operator()(LogLevel level, std::string file, int line)        {            return LogMessage(level, file, line, *this);        }    private:        std::unique_ptr<LogStrategy> _strategy;    };}NS_LOGGER_MUDULE::Logger logger;#define ENABLE_CONSOLE_STRATEGY() logger.UseConsoleStrategy()#define ENABLE_FILE_STRATEGY() logger.UseFileStrategy()#define LOG(level) logger(level, __FILE__, __LINE__)#endif

测试代码:

#include "Logger.hpp"int main(){    using namespace NS_LOGGER_MUDULE;    ENABLE_FILE_STRATEGY();    LOG(LogLevel::DEBUG) << "hello world" << 3.14 << "clear";    sleep(1);    LOG(LogLevel::DEBUG) << "hello world" << 3.14 << "clear";    sleep(2);    LOG(LogLevel::DEBUG) << "hello world" << 3.14 << "clear";    sleep(1);    LOG(LogLevel::DEBUG) << "hello world" << 3.14 << "clear";    sleep(3);    LOG(LogLevel::DEBUG) << "hello world" << 3.14 << "clear";    return 0;}

4、单例模式线程池

4.1、线程池实现

所有的池化技术都是为了提高效率,线程池也一样。

本节代码思路:在线程池构建函数创建线程,并使用数组管理。当调用Start方法时,所有线程执行HandlerTask处理任务。

HandlerTask思路:无限循环,没有任务并且正在运行,则阻塞。没有运行并且没有任务就跳出循环。任务入队列,自动唤醒条件变量。

ThreadPool.hpp:

#ifndef __THREAD_POOL_HPP#define __THREAD_POOL_HPP#include"Logger.hpp"#include"Thread.hpp"#include"Mutex.hpp"#include"Condition.hpp"using namespace NS_LOGGER_MUDULE;using namespace NS_THREAD_MUDULE;using namespace NS_MUTEX_MUDULE;using namespace NS_CONDITION_MUDULE;#include<vector>#include<queue>template<class T>class ThreadPool{private:    voidHandlerTask()    {        while(1)        {            T task;            {                LockGuard lockguard(_mutex);                // 没有任务时                while(_tasks.empty() && _isrunnig)                {                    _slavers_sleep_num++;                    _cond.Wait(_mutex);                    _slavers_sleep_num--;                }                if(!_isrunnig && _tasks.empty())                {                    _mutex.unLock();                    break;                }                task = _tasks.front();                _tasks.pop();            }            LOG(LogLevel::DEBUG) << "quit...";            LOG(LogLevel::DEBUG) << "开始执行任务";            task();        }    }public:    ThreadPool(int slavers_num = 5)        :_isrunnig(false)        ,_slavers_sleep_num(slavers_num)    {        for(int i = 0; i < slavers_num; ++i)        {            // 创建线程            _slavers.emplace_back([this]()            {                this->HandlerTask();            });        }    }    voidEnqueue(T& task)    {        LockGuard lockguard(_mutex);        _tasks.emplace(task);        // 如果正在休息的子线程数量大于0, 则唤醒一个运行任务        if(_slavers_sleep_num > 0)            _cond.Signal();    }    voidStart()    {        if(_isrunnig)            return;        _isrunnig = true;        for(auto& slaver : _slavers)        {            slaver.start();         }    }    voidStop()    {        if(!_isrunnig)            return;        LOG(LogLevel::DEBUG) << "停止执行";        _isrunning = false;        for(auto& slaver : _slavers)        {            slaver.stop();         }    }    voidWait()    {        for(auto& slaver: _slavers)        {            slaver.join();        }    }    ~ThreadPool()    {  }private:    std::queue<T> _tasks; // 任务队列    std::vector<Thread> _slavers;    bool _isrunnig;    int _slavers_sleep_num;    Cond _cond;    Mutex _mutex;};#endif

Main.cc

#include"Logger.hpp"#include"ThreadPool.hpp"#include<memory>#include<cstdlib>#include<ctime>#include<sstream>class task{public:    task() = default;    task(int x, int y)        :_x(x)        ,_y(y)    {  }    voidoperator()()    {        _ret = _x + _y;        LOG(LogLevel::DEBUG) << result();    }    std::string result()    {        std::stringstream ss;        ss << _x << " + " << _y << " = " << _ret;        return ss.str();    }private:    int _x;    int _y;    int _ret;};intmain(){    std::unique_ptr<ThreadPool<task>> tp = std::make_unique<ThreadPool<task>>();    tp->Start();    ENABLE_CONSOLE_STRATEGY();    std::srand(time(nullptr) ^ getpid());    int cnt = 10;    while(cnt--)    {        task t(rand() % 10, rand() % 10)        tp->Enqueue(t);        usleep(100);    }    tp->Stop();    tp->Wait();    return 0;}

结果:

4.2、引入单例模式

单利模式:保证一个类在程序中只有一个实例对象,对外提供使用接口。

单例模式分为:

  • 懒汉式单例模式:惰性加载,需要时创建。
  • 饿汉式单例模式:程序开始时创建。

实践中要用懒汉式单例模式,因为这样可以加快程序启动效率。

下面代码引入懒汉式单例模式:

template<class T>class ThreadPool{private:    voidHandlerTask();    // 私有化构造函数    ThreadPool(int slavers_num = 5);    ThreadPool(const ThreadPool<T>&) = delete;    ThreadPool<T>& operator=(const ThreadPool<T>) = delete;public:    static ThreadPool<T>* Instance()    {    	if(_instance == nullptr)    	{            LockGuard lockguard(_lock);            if(_instance == nullptr)            {                _instance = new ThreadPool<T>();                _instance->Start();                LOG(LogLevel::DEBUG) << "线程池创建...";            }        }        return _instance;    }    voidEnqueue(T& task);    voidStart();    voidStop();    voidWait();    ~ThreadPool() = default;private:    std::queue<T> _tasks;    std::vector<Thread> _slavers;    bool _isrunnig;    int _slavers_sleep_num;    Cond _cond;    Mutex _mutex;// 引入单利模式    static ThreadPool<T>* _instance;    static Mutex _lock;};template<class T>ThreadPool<T>* ThreadPool<T>::_instance = nullptr;template<class T>Mutex ThreadPool<T>::_lock;

细节:

  1. 私有化构造函数,删除掉复制构造和复制重载。保证只有一份实例。
  2. Instance
    接口必须静态化,否则创建第一个对像之前没有对象,无法调用。
  3. 线程池本身也是资源,Instance接口加锁,保证线程安全。
  4. Instance
    接口双if判断,避免后续重复加锁解锁,提高效率。

5、总结

  1. POSIX信号量作为资源预定机制,通过P/V操作实现对共享资源的原子性管理,比互斥锁与条件变量的组合更简洁。

  2. 环形队列生产者消费者模型利用两个信号量分别管理空格资源和数据资源,配合细粒度的生产者锁与消费者锁,实现了更高的并发度。

  3. 日志系统采用策略模式设计,通过多态将日志输出方式(控制台/文件)与日志格式逻辑解耦,便于扩展和维护。

  4. 线程池结合单例模式,实现了线程资源的复用与管理,避免频繁创建销毁线程的开销,并保证了全局唯一实例的线程安全。

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-02 21:56:41 HTTP/2.0 GET : https://f.mffb.com.cn/a/502974.html
  2. 运行时间 : 0.230748s [ 吞吐率:4.33req/s ] 内存消耗:4,805.72kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=e68f0c17f635893fa2e77ef11180603b
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000965s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.001402s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.013831s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.008352s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.001459s ]
  6. SELECT * FROM `set` [ RunTime:0.000614s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.001487s ]
  8. SELECT * FROM `article` WHERE `id` = 502974 LIMIT 1 [ RunTime:0.001239s ]
  9. UPDATE `article` SET `lasttime` = 1783000601 WHERE `id` = 502974 [ RunTime:0.013119s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 67 LIMIT 1 [ RunTime:0.000638s ]
  11. SELECT * FROM `article` WHERE `id` < 502974 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000846s ]
  12. SELECT * FROM `article` WHERE `id` > 502974 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000691s ]
  13. SELECT * FROM `article` WHERE `id` < 502974 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.001594s ]
  14. SELECT * FROM `article` WHERE `id` < 502974 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.001824s ]
  15. SELECT * FROM `article` WHERE `id` < 502974 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.001774s ]
0.233412s