66#include < chrono>
77#include < cmath>
88#include < csignal>
9+ #include < cstddef>
10+ #include < cstdio>
11+ #include < future>
912#include < photon/common/alog.h>
1013#include < photon/common/lockfree_queue.h>
1114#include < photon/io/signal.h>
@@ -501,3 +504,48 @@ SEQ_FUNC bool seq_lockfree_queue_pop(CLockfreeSPSCRingQueueHandle handle,
501504 auto queue = static_cast <LockfreeSPSCRingQueue<iovec, capacity> *>(handle);
502505 return queue->pop (*data);
503506}
507+
508+ // ¶¨Òå sample_callback_
509+ sample_callback sample_callback_ = nullptr ;
510+
511+ SEQ_FUNC void seq_set_sample_callback (sample_callback callback) {
512+ sample_callback_ = callback;
513+ }
514+
515+ SEQ_FUNC void seq_sample_test () {
516+ if (sample_callback_) {
517+ sample_callback_ ();
518+ }
519+ }
520+
521+ // entry
522+ static void *entry (void *arg) {
523+ printf (" entry\n " );
524+ if (sample_callback_) {
525+ sample_callback_ ();
526+ }
527+ printf (" entry done\n " );
528+ return nullptr ;
529+ }
530+
531+ static void e () {
532+ printf (" e\n " );
533+ if (sample_callback_) {
534+ sample_callback_ ();
535+ }
536+ printf (" e done\n " );
537+ }
538+
539+ SEQ_FUNC void seq_sample_coro_test () {
540+ printf (" seq_sample_coro_test\n " );
541+ if (work_pool == nullptr ) {
542+ printf (" work_pool is nullptr\n " );
543+ return ;
544+ }
545+ // work_pool->thread_migrate(photon::thread_create(entry, nullptr));
546+
547+ // Æô¶¯stdÏß³Ì(·ÇphotonÏß³Ì)
548+ std::thread *t = new std::thread (e);
549+ t->join ();
550+ printf (" seq_sample_coro_test done\n " );
551+ }
0 commit comments