Rails 中的 delayed_job 库中的 #delay 持续多长时间?
How long does #delay in the delayed_job library in Rails last?
我正在使用 sidekiq,我刚刚阅读了这个文档:
ActiveRecord
Use delay, delay_for(interval), or delay_until(time) to asynchronously execute arbitrary methods on your ActiveRecord classes.
User.delay.delete_old_users('some', 'params')
User.delay_for(2.weeks).whatever
User.delay_until(2.weeks.from_now).whatever
标准延迟持续多长时间?还是它会立即触发另一个线程中的作业?
您认为这是线程的准确定义吗:
a thread of execution is the smallest sequence of programmed
instructions that can be managed independently by a scheduler, which
is typically a part of the operating system....
更好:
A thread is an execution context, which is all the information a CPU
needs to execute a stream of instructions.
Suppose you're reading a book, and you want to take a break right now,
but you want to be able to come back and resume reading from the exact
point where you stopped. One way to achieve that is by jotting down
the page number, line number, and word number. So your execution
context for reading a book is these 3 numbers.
If you have a roommate, and she's using the same technique, she can
take the book while you're not using it, and resume reading from where
she stopped. Then you can take it back, and resume it from where you
were.
Threads work in the same way. A CPU is giving you the illusion that
it's doing multiple computations at the same time. It does that by
spending a bit of time on each computation. It can do that because it
has an execution context for each computation. Just like you can share
a book with your friend, many tasks can share a CPU.
On a more technical level, an execution context (therefore a thread)
consists of the values of the CPU's registers.
Last: threads are different from processes. A thread is a context of
execution, while a process is a bunch of resources associated with a
computation. A process can have one or many threads.
延迟意味着"do this work as soon as possible somewhere else"。该作业已排入 Redis,可能会在下一毫秒或几小时后执行 - 你不知道。
我正在使用 sidekiq,我刚刚阅读了这个文档:
ActiveRecord
Use delay, delay_for(interval), or delay_until(time) to asynchronously execute arbitrary methods on your ActiveRecord classes.
User.delay.delete_old_users('some', 'params')
User.delay_for(2.weeks).whatever
User.delay_until(2.weeks.from_now).whatever
标准延迟持续多长时间?还是它会立即触发另一个线程中的作业?
您认为这是线程的准确定义吗:
a thread of execution is the smallest sequence of programmed instructions that can be managed independently by a scheduler, which is typically a part of the operating system....
更好:
A thread is an execution context, which is all the information a CPU needs to execute a stream of instructions.
Suppose you're reading a book, and you want to take a break right now, but you want to be able to come back and resume reading from the exact point where you stopped. One way to achieve that is by jotting down the page number, line number, and word number. So your execution context for reading a book is these 3 numbers.
If you have a roommate, and she's using the same technique, she can take the book while you're not using it, and resume reading from where she stopped. Then you can take it back, and resume it from where you were.
Threads work in the same way. A CPU is giving you the illusion that it's doing multiple computations at the same time. It does that by spending a bit of time on each computation. It can do that because it has an execution context for each computation. Just like you can share a book with your friend, many tasks can share a CPU.
On a more technical level, an execution context (therefore a thread) consists of the values of the CPU's registers.
Last: threads are different from processes. A thread is a context of execution, while a process is a bunch of resources associated with a computation. A process can have one or many threads.
延迟意味着"do this work as soon as possible somewhere else"。该作业已排入 Redis,可能会在下一毫秒或几小时后执行 - 你不知道。