Giter Site home page Giter Site logo

Comments (3)

MRkuan avatar MRkuan commented on September 26, 2024

还有 flex_button_event_read 读出事件结果,没有读写锁,也没有线程安全

以上是本人的拙见。。。。

from flexiblebutton.

murphyzhao avatar murphyzhao commented on September 26, 2024

感谢您的反馈 😃

确实会存在多线程安全的问题,后续我考虑下如何简单实现数据互斥,您有好的想法和代码实现也可以直接 PR 提上来 。

from flexiblebutton.

FangXS-github avatar FangXS-github commented on September 26, 2024

像例程中单独创建一个按键任务,即使在任意时刻打断,恢复上下文将继续操作。
操作flex_button全局,只在当前按键任务进行操作,是线程安全的;
只要不在别的任务进行flex_button库的数据操作或其他操作即可;
可以在按键回调任务发送事件,信号量或队列进行数据传递;

如果非要在其他任务操作 flex_button_register:
我推荐的做法是
void other_task()
{
flex_button_register();
semp_give(); // 注册完成 发送信号量解除按键任务阻塞
for(;;){
//..........
}
}
void key_task()
{
semp_take(max_delay); // 等待创建完成进行 扫描工作
for(;;){
flex_key_scan();
os_delay(20);
}
}

from flexiblebutton.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.