Comments (8)
OK, please feel free to ask if you have any questions.
We also have a Slack chatroom for people who want instant replies and talks, you can send me emails to book time and see if any of our team members are online to serve at that time
from photonlibos.
https://join.slack.com/t/photonlibos/shared_invite/zt-1wcmopjw0-wsNZxNtv6teJQxBzm_jKag
Yes you will need a temporary struct, the current create11 implementation basically does a placement-new
operation ,
Line 44 in 7ebf6ba
Thread create has some cost, to minimize it, you can use ThreadPool
By the way, context switch will not happen inside the thread create function call , that means the sub thread (callee) only got its stack allocated. After the caller went to sleep(yield), the sub thread callee will have a chance to run
from photonlibos.
photon::thread_create11()
is the C++11 implementation in thread/thread11.h
.
We also have a photon::thread* photon::thread_create(thread_entry start, void* arg)
in thread/thread.h
BTW, what kind of project do you plan to use this c wrapper in?
from photonlibos.
So how can we call it from C?
photon::thread_create
is a c-style function that creates a photon thread. This may fits better for your needs.
accepts a
void*
instead ofF
can be added?
I suppose this void* is actually a function pointer? You can pass the function pointer (of proper type) directly to photon::thread_create
.
from photonlibos.
what kind of project
Probably langv (https://github.com/vlang/v).
I've never heard of it before, but it looks like a great language (according to the feature-list).
from photonlibos.
Thanks @beef9999 !
Yes, I want to use it internally for V's coroutines/scheduler.
from photonlibos.
Thanks, that's great.
What's the Slack link?
I managed to set it up using thread_create()
. In the C++11 version it's easy to just list all arguments that need to be passed. In thread_create()
there's only one argument. Do I need to use temporary structs to pass multiple arguments, or is there a way to do so like with thread_create11()
?
from photonlibos.
is there a way to do so like with
thread_create11()
?
thread_create11 uses template meta-programming to realize a generic temp struct in order to pass arbitrary number (and types) of arguments. But it is not accessible from C. You have to do it manually in C.
When invoking thread_create(), you have an option to reserved some space in the new stack for the temp struct, so as to avoid an extra allocation for it. The placement new operation mentioned by @beef9999 uses this trick.
from photonlibos.
Related Issues (20)
- Can you provide an interface that reads at least n bytes and reads as many as possible? HOT 11
- ThreadPool.multithread test case occasionally hang in ARM build HOT 1
- Should not use iouring by default HOT 1
- How to join the slack channel HOT 3
- If there is only one connection, what's the best practice of taking full advantage of multiple cores HOT 5
- io_uring cascading engine missing submit HOT 1
- more efficient & effective CI HOT 1
- How do I read a directory and get the list of files? HOT 3
- Can I ask a question. I read the source code about context switch , but have not seen general register save and pop HOT 2
- switch_context has bug. HOT 5
- Missed mutex unlock notification in io_uring engine HOT 6
- Improve event engine of epoll
- [io_uring] Refine submit_wait_by_timer for kernel less than 5.15
- Using ```estring_view``` instead of ```std::string_view``` for APIs, to avoid ABI inconsistency between C++ versions
- photon.fini() will hang with iouring master engine and signalfd HOT 3
- What is 'randomizer' in thread_create for? HOT 2
- install option via cmake? HOT 3
- Issue building on Ubuntu/ARM HOT 11
- [Discussion] Add ENABLE_TLS option HOT 2
- Build fails on fresh Ubuntu 23.04, GCC-13 HOT 11
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from photonlibos.