小编Ale*_*aev的帖子

如何在 Julia 的单独线程上运行函数?

我想在单独的核心上运行一个函数。我编写了一个脚本,可以异步并行运行两次。

const results = Channel()


function my_function()
    delay = rand() * 5
    @info "Task with $delay s"
    @info "Thread $(Threads.threadid())"
    sleep(delay)
    put!(results, delay)
end


errormonitor(@async my_function())
errormonitor(@async my_function())


@info "returned $(take!(results))"
@info "returned $(take!(results))"
Run Code Online (Sandbox Code Playgroud)

但两次都在同一个线程中。

[ Info: Task with 2.9497522378270298 s
[ Info: Task with 4.956428193185428 s
[ Info: Thread 1
[ Info: Thread 1
[ Info: returned 2.9497522378270298
[ Info: returned 4.956428193185428
Run Code Online (Sandbox Code Playgroud)

如何my_function在不同的线程上运行?

julia

5
推荐指数
1
解决办法
886
查看次数

如何在代码本身中找到闪存的大小?

我想在代码本身中获取闪存的限制地址,或者至少是该闪存的大小。

我在文件中只找到了flash的起始地址stm32f302xc.h,没有找到结束地址。

/** @addtogroup Peripheral_memory_map
  * @{
  */

#define FLASH_BASE            0x08000000UL /*!< FLASH base address in the alias region */
#define SRAM_BASE             0x20000000UL /*!< SRAM base address in the alias region */
#define PERIPH_BASE           0x40000000UL /*!< Peripheral base address in the alias region */
#define SRAM_BB_BASE          0x22000000UL /*!< SRAM base address in the bit-band region */
#define PERIPH_BB_BASE        0x42000000UL /*!< Peripheral base address in the bit-band region */
Run Code Online (Sandbox Code Playgroud)

是什么定义对此负责,谢谢。

hal stm32

3
推荐指数
1
解决办法
4722
查看次数

是否可以从抽象类型 julia 之外的其他类型继承?

我有一个无法更改的函数,并且它需要 type ExpectedType

function some_function(some_parameter::ExpectedType)
   ....
   some implementation
   ....
end
Run Code Online (Sandbox Code Playgroud)

我想传递我的 type 对象OtherType

我决定OtherType继承ExpectedType.

struct OtherType <: ExpectedType end
Run Code Online (Sandbox Code Playgroud)

但我收到一个错误:ERROR: invalid subtyping in definition of OtherType

  1. 是否可以从非abst类型继承?
  2. 我怎样才能获得我需要的功能?

julia

3
推荐指数
1
解决办法
215
查看次数

结构本身就包含在内。这个怎么理解?

我热衷于其他人的代码并想了解这里发生了什么。这个结构中存储了什么?

这是C中的某种模式吗?

typedef struct _P_NEXT P_NEXT;
struct _P_NEXT {P_NEXT *p_el;};
Run Code Online (Sandbox Code Playgroud)

c c++

0
推荐指数
1
解决办法
100
查看次数

标签 统计

julia ×2

c ×1

c++ ×1

hal ×1

stm32 ×1