chromium的base源码阅读之Timer

Chromium源码—base基础库说明 Chromium 基础库概览 Chromium 基础库包括的内容十分繁杂,我把其中的主要部分大致分为以下几类: 1. 容器类型 Chromium 的代码主要使用 STL 容器类型,比如 std::vector,std::list,另外 GCC 和 MSVC 提供的 STL 扩展容器类型 hash_map 和 hash_set 也在 Chromium 中使用,不过统一放在 base 名字空间里... 阅读详情

简介

本文介绍chromium的base的timer的源码,地址在https://github.com/chromium/chromium/tree/master/base,我们讨论在base中是如何实现一个timer的。

windows下的timer

我们先来看看windows下如何实现一个简单的timer的

class A
{
public:
    void static CALLBACK TimeProc(HWND hwnd, UINT message, 
                                  UINT idTimer, DWORD dwTime) {
        std::cout << "timer times" << std::endl
    }
};

int main()
{
    SetTimer(NULL, 1, 1000, A::TimeProc);
    MSG msg;
    while(1) {
        if (GetMessage(&msg, NULL, 0, 0)) {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }
    return 0;
}

简单介绍下这个简单的timer,首先执行main函数时,即在主线程上用VC++的api设置一个timer,然后进入消息循环,等到GetMessage获取到消息后去分发执行,如果是WM_TIMER,便会执行那个回调函数TimeProc。

base的timer

base库立于跨平台,所以在实现timer的时候就没有使用vc++的api,同时vc++的api有一个弊端,就是回调函数须是一个C的函数,对于C++中类的成员函数不能使用。

1. 使用

源码位于timer.h|timer.cc中,在注释中可以找到timer的使用方式:

// Sample RepeatingTimer usage:
//
//   class MyClass {
//    public:
//     void StartDoingStuff() {
//       timer_.Start(FROM_HERE, TimeDelta::FromSeconds(1),
//                    this, &MyClass::DoStuff);
//     }
//     void StopDoingStuff() {
//       timer_.Stop();
//     }
//    private:
//     void DoStuff() {
//       // This method is called every second to do stuff.
//       ...
//     }
//     base::RepeatingTimer<MyClass> timer_;
//   };

声明一个要重复执行的timer,在StartDoingStuff中调用Start开启定时器,第一个参数是执行的位置,第二个是时间间隔,然后是执行回调函数的对象和回调函数,之后每隔一段时间就会调用DoStuff,停止定时器就条用Stop函数。

2. 前置知识

base自己建立了一整套自己的体系,包括他自己MessageLoop,thread,TimeDelta等,我们下边也会提到。

3. 源码解读

首先列出.h的代码,我把注释删掉,这样显得简短:

#ifndef BASE_TIMER_H_
#define BASE_TIMER_H_

// IMPORTANT: If you change timer code, make sure that all tests (including
// disabled ones) from timer_unittests.cc pass locally. Some are disabled
// because they're flaky on the buildbot, but when you run them locally you
// should be able to tell the difference.

#include "base/base_export.h"
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/location.h"
#include "base/time.h"

namespace base {

class BaseTimerTaskInternal;
class MessageLoop;

//-----------------------------------------------------------------------------
// This class wraps MessageLoop::PostDelayedTask to manage delayed and repeating
// tasks. It must be destructed on the same thread that starts tasks. There are
// DCHECKs in place to verify this.
//
class BASE_EXPORT Timer {
 public:
  // Construct a timer in repeating or one-shot mode. Start or SetTaskInfo must
  // be called later to set task info. |retain_user_task| determines whether the
  // user_task is retained or reset when it runs or stops.
  Timer(bool retain_user_task, bool is_repeating);

  // Construct a timer with retained task info.
  Timer(const tracked_objects::Location& posted_from,
        TimeDelta delay,
        const base::Closure& user_task,
        bool is_repeating);

  virtual ~Timer();

  // Returns true if the timer is running (i.e., not stopped).
  bool IsRunning() const {
    return is_running_;
  }

  // Returns the current delay for this timer.
  TimeDelta GetCurrentDelay() const {
    return delay_;
  }

  // Start the timer to run at the given |delay| from now. If the timer is
  // already running, it will be replaced to call the given |user_task|.
  void Start(const tracked_objects::Location& posted_from,
             TimeDelta delay,
             const base::Closure& user_task);

  // Call this method to stop and cancel the timer.  It is a no-op if the timer
  // is not running.
  void Stop();

  // Call this method to reset the timer delay. The user_task_ must be set. If
  // the timer is not running, this will start it by posting a task.
  void Reset();

  const base::Closure& user_task() const { return user_task_; }
  const TimeTicks& desired_run_time() const { return desired_run_time_; }

 protected:
  // Used to initiate a new delayed task.  This has the side-effect of disabling
  // scheduled_task_ if it is non-null.
  void SetTaskInfo(const tracked_objects::Location& posted_from,
                   TimeDelta delay,
                   const base::Closure& user_task);

 private:
  friend class BaseTimerTaskInternal;

  // Allocates a new scheduled_task_ and posts it on the current MessageLoop
  // with the given |delay|. scheduled_task_ must be NULL. scheduled_run_time_
  // and desired_run_time_ are reset to Now() + delay.
  void PostNewScheduledTask(TimeDelta delay);

  // Disable scheduled_task_ and abandon it so that it no longer refers back to
  // this object.
  void AbandonScheduledTask();

  // Called by BaseTimerTaskInternal when the MessageLoop runs it.
  void RunScheduledTask();

  // Stop running task (if any) and abandon scheduled task (if any).
  void StopAndAbandon() {
    Stop();
    AbandonScheduledTask();
  }

  // When non-NULL, the scheduled_task_ is waiting in the MessageLoop to call
  // RunScheduledTask() at scheduled_run_time_.
  BaseTimerTaskInternal* scheduled_task_;

  // Location in user code.
  tracked_objects::Location posted_from_;
  // Delay requested by user.
  TimeDelta delay_;
  // user_task_ is what the user wants to be run at desired_run_time_.
  base::Closure user_task_;

  // The estimated time that the MessageLoop will run the scheduled_task_ that
  // will call RunScheduledTask().
  TimeTicks scheduled_run_time_;

  // The desired run time of user_task_. The user may update this at any time,
  // even if their previous request has not run yet. If desired_run_time_ is
  // greater than scheduled_run_time_, a continuation task will be posted to
  // wait for the remaining time. This allows us to reuse the pending task so as
  // not to flood the MessageLoop with orphaned tasks when the user code
  // excessively Stops and Starts the timer.
  TimeTicks desired_run_time_;

  // Thread ID of current MessageLoop for verifying single-threaded usage.
  int thread_id_;

  // Repeating timers automatically post the task again before calling the task
  // callback.
  const bool is_repeating_;

  // If true, hold on to the user_task_ closure object for reuse.
  const bool retain_user_task_;

  // If true, user_task_ is scheduled to run sometime in the future.
  bool is_running_;

  DISALLOW_COPY_AND_ASSIGN(Timer);
};

//-----------------------------------------------------------------------------
// This class is an implementation detail of OneShotTimer and RepeatingTimer.
// Please do not use this class directly.
template <class Receiver, bool kIsRepeating>
class BaseTimerMethodPointer : public Timer {
 public:
  typedef void (Receiver::*ReceiverMethod)();

  // This is here to work around the fact that Timer::Start is "hidden" by the
  // Start definition below, rather than being overloaded.
  // TODO(tim): We should remove uses of BaseTimerMethodPointer::Start below
  // and convert callers to use the base::Closure version in Timer::Start,
  // see bug 148832.
  using Timer::Start;

  BaseTimerMethodPointer() : Timer(kIsRepeating, kIsRepeating) {}

  // Start the timer to run at the given |delay| from now. If the timer is
  // already running, it will be replaced to call a task formed from
  // |reviewer->*method|.
  void Start(const tracked_objects::Location& posted_from,
             TimeDelta delay,
             Receiver* receiver,
             ReceiverMethod method) {
    Timer::Start(posted_from, delay,
                 base::Bind(method, base::Unretained(receiver)));
  }
};

//-----------------------------------------------------------------------------
// A simple, one-shot timer.  See usage notes at the top of the file.
template <class Receiver>
class OneShotTimer : public BaseTimerMethodPointer<Receiver, false> {};

//-----------------------------------------------------------------------------
// A simple, repeating timer.  See usage notes at the top of the file.
template <class Receiver>
class RepeatingTimer : public BaseTimerMethodPointer<Receiver, true> {};

//-----------------------------------------------------------------------------
// A Delay timer is like The Button from Lost. Once started, you have to keep
// calling Reset otherwise it will call the given method in the MessageLoop
// thread.
//
// Once created, it is inactive until Reset is called. Once |delay| seconds have
// passed since the last call to Reset, the callback is made. Once the callback
// has been made, it's inactive until Reset is called again.
//
// If destroyed, the timeout is canceled and will not occur even if already
// inflight.
template <class Receiver>
class DelayTimer : protected Timer {
 public:
  typedef void (Receiver::*ReceiverMethod)();

  DelayTimer(const tracked_objects::Location& posted_from,
             TimeDelta delay,
             Receiver* receiver,
             ReceiverMethod method)
      : Timer(posted_from, delay,
              base::Bind(method, base::Unretained(receiver)),
              false) {}

  void Reset() { Timer::Reset(); }
};

}  // namespace base

#endif  // BASE_TIMER_H_
  • Timer是所有类的基类,也是在这个类里实现了所有的功能,一般我们不会直接用到
  • BaseTimerMethodPointer这个类是OneShotTimer和RepeatingTimer实现的基础,主要是提供给他俩是否是重复性的和接受回调的类,使用是不会用到
  • OneShotTimer这个类是只执行一次的回调函数的实现
  • RepeatingTimer这个类就是重复性的执行回调函数的实现
  • DelayTimer这个类类似于OneShotTimer,调用reset时,处于激活状态,回调函数调用后处于生效状态,直到下一次条用reset,另外是在声明这个类的对象时就需要指定回调函数,同时还不能中途更换回调函数
3.1 class Timer简介

然后我们主要class Timer的实现,这也是我们这篇的核心
timer有两个构造函数,第一个有两个参数,retain_user_task表示是否要保存要执行的回调函数,也就是这里的task以便之后可以重用,is_repeating这个定时器是不是重复性的。第二个构造函数,post_from表示的是记录使用,没有实际用处,就是记录函数执行的位置,可以说记录调用这个函数的位置,delay时间间隔,user_task是要执行的回调函数,is_repeating重复性的定时器。
然后下边也是定时器常用的api,开启(start),结束(stop)等。
简单介绍下成员:

  • scheduled_task_是对user_task执行的包装,是BaseTimerTaskInternal类的对象,这个类是用来进行一些条件判断和最终把包装的函数抛到线程的事件循环中,然后由事件循环调用,然后调用回调函数。
  • scheduled_run_time_这个是我们在开启定时器,指定了偏移时间后计算得到的task执行的时间
  • desired_run_time_这个和schedule_run_time的含义也类似,一个例外是这个会在reset时重新设置task的执行时间,使用它和schedule_run_time可以来判断是不是要重用已经抛出去的task.
3.2 事件循环机制

我们来提一点关于chromium的时间循环机制。我们启动一个线程的时候,需要指定这个线程事件循环(messageloop),代码在messageloop.cc|.h中,然后这个线程就进入了事件循环,然后我们要是想要这个线程做一些事情,我们就需要向这个messageloop设置一些task,我们简单的来看一下这个messageloop使用的接口:

  void PostTask(
      const tracked_objects::Location& from_here,
      const base::Closure& task);

  bool TryPostTask(
      const tracked_objects::Location& from_here,
      const base::Closure& task);

  void PostDelayedTask(
      const tracked_objects::Location& from_here,
      const base::Closure& task,
      base::TimeDelta delay);

  void PostNonNestableTask(
      const tracked_objects::Location& from_here,
      const base::Closure& task);

  void PostNonNestableDelayedTask(
      const tracked_objects::Location& from_here,
      const base::Closure& task,
      base::TimeDelta delay);

  int SendTask(const tracked_objects::Location& from_here,
      const base::Closure& task, int timeout = -1);

这里的task就是我们要做的事情,postDelayTask就是我们timer会用到的接口,表示一段延迟时间后去运行这个task。然后messageloop通过messagepump来进行具体的实现,messageloop有三种类型(default,ui,io),同时使用messagepump来实现跨平台。

3.3 timer的过程

我们来接下来详细的梳理下这个timer的过程,从start开始:

void Timer::Start(const tracked_objects::Location& posted_from,
                  TimeDelta delay,
                  const base::Closure& user_task) {
  SetTaskInfo(posted_from, delay, user_task);
  Reset();
}

start里调用两个函数,SetTaskInfo只是将task的相关消息获得。然后我们看Reset函数:

void Timer::Reset() {
  DCHECK(!user_task_.is_null());

  // If there's no pending task, start one up and return.
  if (!scheduled_task_) {
    PostNewScheduledTask(delay_);
    return;
  }

  // Set the new desired_run_time_.
  desired_run_time_ = TimeTicks::Now() + delay_;

  // We can use the existing scheduled task if it arrives before the new
  // desired_run_time_.
  if (desired_run_time_ > scheduled_run_time_) {
    is_running_ = true;
    return;
  }

  // We can't reuse the scheduled_task_, so abandon it and post a new one.
  AbandonScheduledTask();
  PostNewScheduledTask(delay_);
}

首先判断是否已经有在运行的scheduled_task_(或者说已经抛出去但是还未运行),如果没有的话我们通过task来构造scheduled_task_然后抛到事件队列中运行,如果有在运行的scheduled_task_的话,我们要获得这个当前的task的运行的时间,如果这个时间大于正在运行的scheduled_task_的时间,表明我们其实可以重用这个正在运行的scheduled_task_,以此通过scheduled_task_来运行task,最后运行回调函数。如果正在运行的scheduled_task_的时间是大于当前的task需要运行的时间,需要抛弃掉在运行的scheduled_task_,然后构造新的scheduled_task_来运行。

然后我们看看关键的函数PostNewScheduledTask的实现:

void Timer::PostNewScheduledTask(TimeDelta delay) {
  DCHECK(scheduled_task_ == NULL);
  is_running_ = true;
  scheduled_task_ = new BaseTimerTaskInternal(this);
  ThreadTaskRunnerHandle::Get()->PostDelayedTask(posted_from_,
      base::Bind(&BaseTimerTaskInternal::Run, base::Owned(scheduled_task_)),
      delay);
  scheduled_run_time_ = desired_run_time_ = TimeTicks::Now() + delay;
  // Remember the thread ID that posts the first task -- this will be verified
  // later when the task is abandoned to detect misuse from multiple threads.
  if (!thread_id_)
    thread_id_ = static_cast<int>(PlatformThread::CurrentId());
}

首先设置标致为在运行,然后new一个BaseTimerTaskInternal,把他抛到这个线程的事件循环中等待运行,一段时间后会运行BaseTimerTaskInternal的run函数。计算时间和设置线程id。然后我们来看BaseTimerTaskInternal的Run函数和Abandon函数:

  void Run() {
    // timer_ is NULL if we were abandoned.
    if (!timer_)
      return;

    // *this will be deleted by the task runner, so Timer needs to
    // forget us:
    timer_->scheduled_task_ = NULL;

    // Although Timer should not call back into *this, let's clear
    // the timer_ member first to be pedantic.
    Timer* timer = timer_;
    timer_ = NULL;
    timer->RunScheduledTask();
  }

  // The task remains in the MessageLoop queue, but nothing will happen when it
  // runs.
  void Abandon() {
    timer_ = NULL;
  }

首先会判断timer_是不是为空,当这个scheduled_task_被执行Abandon后就为空,不为空表示并未被abandon,然后将这个scheduled_task_置空,这样去掉这个引用,在运行这个函数后自动释放这个对象,然后去运行真正的task:RunScheduledTask

void Timer::RunScheduledTask() {
  // Task may have been disabled.
  if (!is_running_)
    return;

  // First check if we need to delay the task because of a new target time.
  if (desired_run_time_ > scheduled_run_time_) {
    // TimeTicks::Now() can be expensive, so only call it if we know the user
    // has changed the desired_run_time_.
    TimeTicks now = TimeTicks::Now();
    // Task runner may have called us late anyway, so only post a continuation
    // task if the desired_run_time_ is in the future.
    if (desired_run_time_ > now) {
      // Post a new task to span the remaining time.
      PostNewScheduledTask(desired_run_time_ - now);
      return;
    }
  }

  // Make a local copy of the task to run. The Stop method will reset the
  // user_task_ member if retain_user_task_ is false.
  base::Closure task = user_task_;

  if (is_repeating_)
    PostNewScheduledTask(delay_);
  else
    Stop();

  task.Run();

  // No more member accesses here: *this could be deleted at this point.
}

然后来看这个函数,之前我们有说可能会重用schedule_task_,但是没有说怎么重用,这里是这样的,我们会检查这个运行的schedule_task_是不是正好是我们希望的时间,如果不是的话,我们需要计算下偏移然后会重新抛回到事件循环中,如果不是重用的话,且运行的时间正好是我们希望的时间,就去运行我们的task:task.Run();
同时如果是要重复性的,我们还是要继续创建新的schedule_task_来运行,否则stop这个定时器。

3.4 注意

到这里我们就讲完了整个的流程,我们需要注意的一点是,为什么他要借助scheduled_task_来运行我们的task呢,如果我们只用task,我们就没办法来实现重用的这个概念,因为可能事件队列里正在运行的task和我即将要运行的task是不一样的,如果有了scheduled_task_作为一层包装后,重用时task已经被重置了,所以scheduled_task_可以放心的调用task了,而不用担心本次运行的task和上次运行的task不一致的现象。

3.5 代码实现

如果实在主线程中运行的话可以参照timer.h里的注释,如果需要创建一个线程,同时需要在这个线程里运行这个timer的话可以这样跑起来:

class MyClass
{
 public:
     void StartDoingStuff() {
     	timer_.Start(FROM_HERE, TimeDelta::FromSeconds(1),
                     this, &MyClass::DoStuff);
    }
     void StopDoingStuff() {
     	timer_.Stop();
     }
   private:
        void DoStuff() {
        	// This method is called every second to do stuff.
       		...
     }
     base::RepeatingTimer<MyClass> timer_;
};

MyClass myClass;
base::Thread thread_;
thread_.Start();
thread_.message_loop()->PostTask(FROM_HERE, 
		            base::Bind(&MyClass::StartDoingStuff, base::Unretained(myClass)));

完

Chromium入坑之旅:base库之timer时间操作学习 base::TimeDelta s=秒,ms=毫秒,us=微秒,ns=纳秒; 1s=1000ms=1000000us=1000000000ns; int main() { std::cout << "------TimeDelta------\n"; std::cout << L"FromDays(天):" << base::TimeDelta::FromDays(1)<<"\n"; std::cout << L"FromHours(小 阅读详情

相关推荐

用C++与Qt实现Markdown实时预览编辑器

Markdown作为一种轻量级标记语言,凭借简洁的语法被广泛用于技术文档、笔记和博客写作。与纯文本编辑相比,实时预览功能能够显著提升写作效率,它背后依赖从语法解析到HTML渲染再到界面刷新的完整链路。在桌面端开发中,C++配合Qt框架可以提供高性能的原生控件与Web渲染能力,成为构建此类工具的理想选择。Qt WebEngine结合QWebChannel实现C++与JavaScript的双向通信,配合防抖机制,便能打造流畅的实时预览体验。本文从Markdown解析原理出发,深入讲解如何借助cmark解析库和Q

weixin_33827731的博客 356

chromium中的base库 ipc进程间通信 ChannelProxy分析

1. chromium进程通信的基本模式 进程间通信,叫做IPC(Inter-Process Communication),在Chrome不多的文档中,有一篇就是介绍这个的,在这里。Chrome最主要有三类进程,一类是Browser主进程,我们一直尊称它老人家为老大;还有一类是各个Render进程,前面也提过了;另外还有一类一直没说过,是Plugin进程,每一个插件,在Chrome中都是以进程的形式呈现,等到后面说插件的时候再提罢了。Render进程和Plugin进程都与老大保持进程间的通信,Rende.

sway913的博客 2180

C++初学者实战进阶:八大开源项目深度解析与学习路径

C++编程语言作为系统级开发的核心工具,其学习路径从语法掌握到项目实战是关键跨越。理解计算机科学基础原理,如数据结构、算法、内存管理和操作系统交互,是构建复杂软件系统的基石。在工程实践中,网络编程、并发处理和性能优化等技术价值尤为突出,广泛应用于后端服务、游戏开发、高频交易等核心场景。本文聚焦于通过精选开源项目进行实战学习,其中TinyWebServer展示了事件驱动和线程池在高性能网络服务中的应用,而simdjson则揭示了利用SIMD指令集进行数据级并行优化的前沿技术。这些项目覆盖了从I/O多路复用到无

快马扬鞭须努力! 439

Chromium 基础库使用说明

转自:https://www.zybuluo.com/rogeryi/note/56894 Chromium 基础库使用说明 chromiumbase 作者: 易旭昕 (@roger2yi) Chromium 提供了一个类似 WTF 的基础库,甚至包含了更多的内容。这个基础库在 Blink 之外被广泛使用(Blink 里面仍然使用的是 WTF),了解它的使用对我们实际的代码编写是十分重要的。本文主要介绍 Chromium 基础库包括的主要内容,并详细说明一些重要类型的使用方式。如果需要了解某...

along 1989

base基础库

base基础库是从Chromium 源码中提取,实现跨平台的基础库。

shunzi5201314a的专栏 610

chromium-base:修剪过的 Chromium 基础库,基于 zcbenzbase-minimal 和 mini_chromium,但有更多有用的东西。 目前仅在 linux 和 windows 下工作

最小基数 修剪 Chromium 的基础库,只需将base.gyp:base添加到您的base.gyp:base文件即可使用它们。 建造 $ cd chromium-base $ gyp --depth=. base.gyp -I src/build/common.gypi $ ninja -C out/Debug

007.chromium编译进阶-cookie明文存储

本文介绍了如何修改Chromium源码,使浏览器以明文而非加密方式存储Cookie,便于实现异地Cookie同步。文章首先分析了Chromium默认的Cookie加密存储机制,指出不同环境因密钥不同导致Cookie无法共享的问题。然后详细说明了修改sqlite_persistent_cookie_store.cc文件的具体步骤,包括添加头文件引用和修改两处关键代码。修改后编译运行,测试显示Cookie已明文存储在value列而非加密的encrypted_value列,实现了跨设备Cookie共享。

w1101662433的博客 1079

ESP32拓展板DIY全攻略:从零打造你的传感器控制中心(附PCB设计文件)

本文详细介绍了如何从零开始DIY ESP32拓展板,打造多功能传感器控制中心。内容涵盖项目规划、硬件设计、PCB布局、制作测试全流程,并提供进阶优化建议和实战案例。特别适合嵌入式硬件爱好者学习ESP32拓展板开发,实现各类传感器的高效集成与控制。

blockchain9miner的博客 1090

不装客户端也能快速拿到八大网盘直链?LinkSwift 网盘直链下载助手一次讲清

想把网盘里的文件搬下来,可官方客户端在你的系统上装不了;找解析站又不放心把文件链接过一遍第三方服务器。LinkSwift(Online-disk-direct-link-download-assistant,即"网盘直链下载助手"的修改版)是一个基于用户脚本的网盘直链下载工具,全程在浏览器里跑完:在网盘网页上选中文件,就能拿到真实直链地址,交给 IDM、aria2 这类下载工具接着下载。 ##

gitblog_00811的博客 295

西门子PLC实战:基于1200/1500的工业物联网MQTT通讯全解析

本文详细解析了如何在西门子S7-1200/1500系列PLC上实现工业物联网MQTT通讯。通过从硬件准备、网络配置到TIA Portal中MQTT_Client功能块的实战编程,手把手指导工程师打通车间数据桥梁,解决信息孤岛问题,实现PLC数据高效上云或设备间互联。

whisky的博客 1099

Flutter加载本地HTML的优雅解决方案:轻松实现富文本展示

通过以上步骤,我们实现了Flutter加载本地HTML的完整流程,并简单介绍了如何通过WebView与HTML页面进行交互。HTML文件作为一种灵活、易维护的富文本展示方式,能有效提升Flutter应用的内容呈现能力。这种方法在展示新闻、资讯或帮助文档等内容时非常有用,能够让开发者灵活调整内容的样式和排版。希望这篇文章能对你在Flutter开发中的HTML加载有所帮助!

四楼没电梯的专栏 3666

xerj autoindex 提示数据集被服务器 REFUSED:索引是否全丢、如何修复与重建

**导读**:当服务端对某个数据集(dataset)的建索引或 mapping 安装请求返回 HTTP 400 时,`xerj autoindex` 会把该数据集涉及的文件记录为 junk(垃圾文件),继续索引其余所有数据集,并以退出码 3 结束——你只损失这一个数据集,而不是整个索引。本文基于 xerj 仓库源码与端到端验证记录,详解"拒绝(refusal)"的判定规则、终端输出、记录位置、重建

gitblog_00314的博客 447

sysbench安装(在线&离线)

sysbench下载、安装、编译和异常处理方法

m0_61066945的博客 8776

aarch64平台Qt 5.14.2静态编译实战指南

静态链接是嵌入式Linux系统实现‘单二进制交付’的核心技术,其本质是在编译期将Qt库、C运行时及依赖模块(如OpenSSL、fontconfig)全部内联进可执行文件,消除运行时动态链接器依赖。该方案显著提升启动性能与环境兼容性,特别适用于无包管理、精简rootfs、musl或裁剪glibc的ARM64工业设备。技术关键在于交叉工具链可控构建、Qt源码级configure参数精准裁剪(如-no-icu、-openssl-linked、-sysroot),以及aarch64 ABI适配下的符号解析确定性。本

weixin_33858485的博客 510

北斗导航 | 基于LSTM-KF融合的北斗卫星定位算法研究框架

针对北斗卫星导航系统在复杂环境下存在的多路径效应、非视距传播等问题,提出一种基于长短期记忆网络(LSTM)与卡尔曼滤波(KF)的组合定位算法。通过LSTM网络建模定位误差的非线性特征,结合卡尔曼滤波实现动态噪声抑制,构建"粗定位-LSTM校正-卡尔曼滤波优化"的三级处理架构。实验表明,融合算法较传统方法定位精度提升42.7%,均方根误差降低至1.2米。

尘世冰封的专栏 930

YOLO11涨点优化:loss优化 | 一种新的基于Wasserstein距离的小目标检测评估方法,助力小目标涨点

提出了一种新的基于Wasserstein距离的小目标检测评估方法,通过它们对应的高斯分布计算它们之间的相似性

①订阅者答疑群聊服务;②FDE:工业缺陷检测项目;③paper/创新算法指导;④免费提供YOLO创新涨点推荐顾问Skill和AI小怪兽数字分身; 1028

Qt5.14.2 aarch64静态交叉编译实战指南

静态链接是嵌入式Linux应用实现单文件部署、零依赖运行与启动确定性的关键技术路径。其核心原理在于将应用程序及其全部用户态依赖(如zlib、OpenSSL、ICU等)统一使用目标平台工具链编译为静态库,并在链接阶段完成符号解析与归档,从而消除运行时动态加载风险。该技术显著提升工业边缘设备(如RK3399、Hi3516)的部署鲁棒性与运维可控性,广泛应用于网关GUI、工控HMI及安全敏感型终端场景。本文聚焦Qt5.14.2在aarch64架构下的完整静态交叉编译实践,涵盖Linaro GCC 9.4工具链选型

weixin_33913332的博客 267

YOLO11改进|注意力机制篇|引入ELA注意力机制

YOLO11添加ELA注意力机制

A1983Z的博客 3657

Umbrella日推工具:Rust+Tauri构建个性化信息聚合桌面应用

在信息过载时代,高效获取高质量技术内容成为开发者面临的普遍挑战。传统方式如社交媒体算法推荐、RSS订阅和邮件推送各有局限,难以平衡信息广度与深度。信息聚合与过滤技术应运而生,通过抓取器从多源获取数据,结合关键词、时间等过滤器实现精准筛选,最终通过渲染器生成定制化内容。这种技术方案能有效降低信息噪音,提升获取效率,尤其适合需要持续追踪特定领域动态的技术从业者。以Umbrella为代表的桌面工具,采用Rust+Tauri技术栈,将这一理念工程化实现,通过可配置的源管理和过滤规则,为开发者打造个性化的“日推”信息

weixin_33971977的博客 377

GibbsCAM软件二次开发:GibbsCAM软件API接口详解

API(Application Programming Interface,应用程序编程接口)是一种允许不同软件之间进行通信的接口。在GibbsCAM软件中,API提供了与外部程序交互的能力,使得开发者可以利用GibbsCAM的强大功能进行二次开发,定制化满足特定的制造需求。GibbsCAM的API主要基于.NET框架,使用C#或VB.NET等语言进行编程。在GibbsCAM软件中,通过API接口创建自定义几何形状是实现复杂零件设计和加工策略定制的关键步骤。

kkchenjj的博客 1506

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

Material UI 测试体系全指南:从单元测试到端到端测试的全链路工程实践

本指南基于 Material UI 官方仓库的 [test/README.md](https://link.gitcode.com/i/021ce71d1a2d4fde285c97ff36cfc9ca),系统讲解这个大型 monorepo 项目分层的测试策略与工程化细节:既有基于 Vitest 的单元/集成测试,也有覆盖真实浏览器环境的 vitest browser mode、视觉回归与端到端测试

gitblog_00961的博客 350

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

Chromium base库介绍

AtExitManager 类似于linux下的atexit,注册退出清理函数,不过base库的实现机制是利用了C++的RAII。void exit_first(void *data) { LOG(INFO) << "first"; }void exit_last(void *data) { LOG(INFO) << "second"; }void exit_task(void *data) { L

zyfforlinux 7381

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

chromium basethread使用

不会写博客。慢慢学着写吧。将chromium的base模块分离出来,使用thread方式 #include "stdafx.h" #include #include "./base/threading/thread.h" #include "./base/bind.h" #include "./base/callback.h" #include "./base/message_

moonmuzi的博客 751

Chromium Base库中常用的功能

Chromium Base库中常用的功能

silenceye的专栏 896

chromium - 测试程序使用base空间的类

上个实验,只在chromium中加了一个标准的win32console的工程,现在实验了,使用base命令空间的类的工程修改。不只是程序要包含base类的头文件, Z:\chromium\src\base\test\BUILD.gn 也要修改,依赖base命名空间,才能编译过。

博客标题不能为空 742

chromium的base源码阅读之Callback一

简介 本文描述下chromium使用base库中的callback,相关代码位于base库的根目录下的callback及callback相关,bind及bind相关的,本系列本人只是简单说一下自己的感受,有些存在的问题还望大家一块讨论。 相关base库timer讲解可参考 chromium的base源码阅读之Timer. callback是chromium自己封装的回调函数,需要配合bind使用,...

leapmotion的博客 1252
上一篇: V8的HeapProfiler简单解析
下一篇: C函数调用过程
leapmotion
博客等级 码龄12年 835粉丝 51原创
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值