Coroutine Patterns and How to Use Them: Problems and Solutions Using Coroutines in a Modern Codebasedev@gmail.com ## Outline • Motivation • Overview • Patterns • Lifetime • Exceptions • RAII • Synchronization ## • Conclusions ## Motivation • 40 years of • Experience • Accumulated knowledge ![Ima 0839ae14710dcbb38ddda7e6a7f799/p14_1.jpg) ## Patterns • Lifetime • Exceptions • RAII • Synchronization ## Lifetime ## Lifetime • Lots of worries • Use Structured Concurrency $ ^{[1]} $ • ASAN join async work in classes • Don’t use blockingWait() in a destructor Synchronization # Synchronization Needed? ## Synchronization No shared access? → No int a = 10; co_await reschedule_on_current_executor;0 码力 | 70 页 | 1.45 MB | 1 年前3
A Simple Rollback System in C++0 码力 | 58 页 | 6.61 MB | 1 年前3
Concurrency<< "\n"; }, 42}; my_thread.join(); } ## STD::COUNTING_SEMAPHORE Lightweight synchronization primitive that can control access to a shared resource Maintains an internal counter Calls Some things need to happen before other things Some things can’t happen at the same time synchronization ## PARALLELISM Definition # “Multiple logical threads of execution with no inter-task dependencies” goods_thread.join(); debts_thread.join(); create_report(net_worth, durable_goods, long_term_debts); ## SYNCHRONIZATION: THREAD CREATION Creating a thread synchronizes the parent and child threads All memory changes0 码力 | 160 页 | 2.91 MB | 1 年前3
C++ Memory Model: from C++11 to C++23$$ ## Synchronization ## ADDRESSING THE ELEPHANT IN THE ROOM  ## V olatile • Volatile is not a synchronization tool • /p50_1.jpg) JF Bastien Deprecating volatile What does volatile mean? Colloquially ## Synchronization cont ## Compiler Code Barriers ## Prevent compiler from moving reads or writes across the barrier sum + 200);}; fmt::print("answer is {} \n", prom2.get_future().get()); ## Synchronization Tools • std::mutex, std::conditional_variable • std::lock_guard – RAII helper for locking0 码力 | 112 页 | 5.17 MB | 1 年前3
Spring Framework 1.2.x ChangelogDataSourceUtils to catch Throwable on "Connection.close()" * DataSourceUtils uses lower synchronization order for delegating handles (such as * JdbcTemplate logs SQLWarnings at debug instead of warn * reworked Hibernate JTA transaction synchronization to expose "beforeCompletion" exceptions to the caller * Hibernate JTA transaction synchronization does not call "setRollbackOnly" ; on * reworked Hibernate session synchronization to properly work with WebSphereExtendedJTATransactionLookup on WAS 6.0/6.1 $ ^{*} $ removed special Session reconnection check for Hibernate 3.1 RC10 码力 | 94 页 | 267.57 KB | 2 年前3
Spring Framework 1.2.8 Changelog34; method, else determines target class on demand * refined ThreadLocalTargetSource's synchronization to guarantee thread-safe destruction on shutdown * deprecated AbstractLazyInitTargetSource through SessionBrokerSessionFactory * added "isOpen" assertions to Hibernate Session synchronization, seamlessly removing dangling Sessions (fail-safe) * refined HibernateTransactionManager and Package org.springframework.transaction * optimized TransactionSynchronizationManager to perform synchronization sort lazily (in "getSynchronizations") * added "defaultTimeout" bean property0 码力 | 89 页 | 254.65 KB | 2 年前3
Spring Framework 1.2.6 Changeloginterface now, assuming that the contained disconnected data is serializable * refined JTA synchronization in DataSourceUtils to release JDBC Connection on suspend (for JBoss JTA compatibility) * relaxed through SessionBrokerSessionFactory * added "isOpen" assertions to Hibernate Session synchronization, seamlessly removing dangling Sessions (fail-safe) * refined HibernateTransactionManager and Package org.springframework.transaction * optimized TransactionSynchronizationManager to perform synchronization sort lazily (in "getSynchronizations") * added "defaultTimeout" bean property0 码力 | 83 页 | 236.45 KB | 2 年前3
Spring Framework 1.2.1 ChangelogJTA/Spring transactions * fixed SessionFactoryUtils for Hibernate 2.1 to not prevent transaction synchronization when allowCreate=false * fixed LocalSessionFactoryBean for Hibernate3 to use connection release impls * redefined "allowCreate" flag: allowCreate=false does not prevent transaction synchronization (e.g. with JTA) * deprecated "closePersistenceManager/BrokerIfNecessary" methods in favor methods in favor of "releaseSession" (for both Hibernate2, Hibernate3) * JTA Session synchronization detects read-only status of Spring-managed transaction (for both Hibernate2, Hibernate3) * Hibernate30 码力 | 69 页 | 197.87 KB | 2 年前3
Spring Framework 1.2.7 Changelog34; method, else determines target class on demand * refined ThreadLocalTargetSource's synchronization to guarantee thread-safe destruction on shutdown * deprecated AbstractLazyInitTargetSource through SessionBrokerSessionFactory * added "isOpen" assertions to Hibernate Session synchronization, seamlessly removing dangling Sessions (fail-safe) * refined HibernateTransactionManager and Package org.springframework.transaction * optimized TransactionSynchronizationManager to perform synchronization sort lazily (in "getSynchronizations") * added "defaultTimeout" bean property0 码力 | 87 页 | 248.22 KB | 2 年前3
Spring Framework 1.1.5 ChangelogSessionFactoryUtils' Session lookup code (when using both JTA synchronization and Spring synchronization) * refined SessionFactoryUtils' JTA synchronization to unbind the Session as early as possible (earlier (earlier for a commit) * refined AbstractLobType' JTA synchronization to close the LobCreator as early as possible (earlier for a commit) * fixed NPE in HibernateTemplate's "iterate(queryString, value)" pattern matching via the ServletContext Package org.springframework.orm * fixed Hibernate/JTA synchronization to also work with EJB remote transaction propagation (with >1 thread involved) * fixed H0 码力 | 57 页 | 166.71 KB | 2 年前3
共 1000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 100
相关搜索词
coroutine patternssynchronizationRAIIexception handlinglifetime managementrollback systemdeterministic simulationnetwork synchronizationinput predictiongame state managementConcurrencyparallelismData RacesMutexesatomic operationsC++内存模型原子操作内存顺序数据依赖性编译器重排Spring FrameworkAOPBeanFactoryTransaction ManagementJDBCJMSVelocityViewResolverHibernateTemplateAbstractBeanFactoryDispatcherServletTransactionManagerJdbcTemplateSpring ApplicationContextBeanUtilsApplicationContextPropertyPlaceholderConfigurerDataBinderException HandlingContextTransactionProxyAOP框架事务管理视图解析器













